问题描述
我创建了一个主要方法,这样我就可以从命令行运行测试并将变量发送到帮助方法。这是主文件:
import pytest
import sys
from tests import test_sample
class Main:
# Run the tests
def __init__(self):
pass
pytest.main([sys.argv[0]])
variable = sys.argv[0]
test_sample.TestSample()
我正在使用在命令行中传递的变量来设置一些助手:
variable = main.Main.variable
def random_function(variable):
return pass
这是我要在主类中运行的测试示例:
from helpers import helpers
class TestSample():
def test_random_test(self):
helpers.random_function()
pass
我不确定为什么,但是我仍然看到此错误:
AttributeError:模块'tests.test_sample'没有属性'TestSample'
当我在命令行中运行此命令时:
python3 main.py变量
我需要更改什么以便模块可以被主类识别?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)