我可以将单个conftest.py用于不同的测试目录吗?

时间:2017-08-15 11:45:34

标签: pytest

这是我的测试目录:

test/
    unit/
        some test files 
        conftest.py
    acceptance/
        some test files
        conftest.py

现在有两个针对灯具的conftest文件。我可以将它们合并到一个conftest.py文件中吗?如果是,我应该在哪里保持这种共同的conftest.py

1 个答案:

答案 0 :(得分:7)

You can combine the fixtures into a conftest.py file within the top-level test directory. Per this documentation中添加onclick但不执行href =“url”,conftest文件是每个目录。 conftest文件(以及其中的fixture和插件)应该可用于测试该目录和子目录中的文件。如果您这样做,我建议您通过添加test文件(the note in this documentation)将__init__.py目录放入python包中。