我的目录中有如下目录结构
tests
|
|__A
| |__test_1.py
|__B
| |__test_2.py
|__C
| |__test3.py
|__D
| |__test4.py
|__test_setup
| |__conftest.py
|__pytest.ini
所以我的 pytest.ini 如下所示
[测试] confcutdir = 测试/test_setup/ rootdir = 测试/test_setup
所以我的问题是我想让 pytest 查看 conftest.py 的 tests/test_setup 一种选择是将 conftest.py 保留在测试目录级别(这不是一个好的选择)
当我尝试运行时:
py.test --multihost-config=test.yaml test_1.py -q -s
它无法加载具有一堆固定装置的 conftest.py。
我做得对还是我的 pytest.ini 搞砸了?
请推荐。 提前致谢
请您参考如下方法:
conftests 是某些目录的本地插件
如果你想以不同的方式使用它们, 您需要创建插件并将它们引用为您要使用的插件
(插件可以只是你在本地比赛中命名的 python 模块)
通常你不应该导入一个 fixture
因为每个导入站点都被认为是一个新的固定装置(即使对于 session 范围也是如此)
相反,您应该声明包含固定装置的模块
