问题描述
class TestScenario:
binary = './foo'
def test_one(self,fixture1,fixture2):
assert subprocess.check_call(binary,fixture1) == fixture2
def test_two(self,fixture3,fixture4):
assert subprocess.check_call(binary,fixture4) == 'OK'
# about 10 more tests
我在 conftest.py 中也有一个超级整洁的 pytest_generate_tests
,它从与 fixture1
位于同一文件夹中的目录 testdata
中填充夹具(Metafunc.module.__file__
等)内容.
问题是我在对应目录下有几十个类似的二进制文件不同的内容(结构相同,内容和文件数量不同)。
我有一个想法:将 test_foo.py
、test_bar.py
等放在每个 foo
和 bar
二进制文件附近,然后在内部编写一个继承 TestScenario
和 class TestFoo(TestScenario):
binary='./foo'
的类{1}}。
├── foo
│ ├── foo.py
│ ├── testdata
│ │ └──...
│ └── test_foo.py
├── bar
│ ├── bar.py
│ ├── testdata
│ │ └──...
│ └── test_bar.py
│── ...many more similar subtrees
└── conftest.py
树看起来像这样:
test_foo.py
TestScenario
的内容:
问题是:conftest.py
放在哪里以及如何导入?我不能把它放在 TestScenario
里面(因为它不是夹具),而且我不想用 test_[foo|bar|baz|foobar].py
作为模块安装文件(或管理导入路径)。
我在不同的目录中有几十个类似的 npm install [email protected] --save
ng server
文件,我想尽可能避免重复代码,但我找不到共享代码的方法。
问题:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)