我有一个位于 conftest.py 中的夹具。
@pytest.fixture(scope='module', autouse=True)
def my_fixture():
"""
Some useful code
"""
结构如下:
tests
|
|--first_folder
| |--__init__.py
| |--test_first_1.py
| |--test_first_2.py
|
|--second_folder
| |--__init__.py
| |--test_second_1.py
|
|--__init__.py
|--conftest.py
|--test_common_1.py
我希望该夹具仅在内部文件夹测试脚本中自动使用:在test_first_1.py、test_first_2.py、test_second_1.py中,但不在 test_common_1.py中。
我可以在每个内部文件夹中使用该夹具创建 conftest,但我不想复制代码
有什么方法可以将 conftest 中的夹具应用到内部文件夹中的测试脚本并在公共文件夹测试脚本中忽略它?