Python 是什么使得py.test调用根目录中的conftest.py?
我有以下目录结构:Python 是什么使得py.test调用根目录中的conftest.py?,python,pytest,Python,Pytest,我有以下目录结构: root --- conftest.py | | ----- dev | | ---- conftest.py | ---- other python files 如果在dev目录中运行py.test,则会调用根目录中的conftest.py。我还不知道为什么。我没有设置PYTHONPATH环境变量。来自: 通过加载命令行调用推断的所有conftest.py文件: 如果未指定测试路径,请使用当前目录
root --- conftest.py
|
|
----- dev
|
|
---- conftest.py
|
---- other python files
如果在dev目录中运行py.test,则会调用根目录中的conftest.py。我还不知道为什么。我没有设置PYTHONPATH环境变量。来自:
通过加载命令行调用推断的所有conftest.py文件:
- 如果未指定测试路径,请使用当前目录作为测试路径
- 如果存在,则相对于第一个测试路径的目录部分加载conftest.py和test*/conftest.py
如果您没有为我指定测试路径,则从根目录加载conftest.py似乎是一种记录在案的行为。您期望的行为是什么?您是说您正在运行“py.test dev”还是“cd dev”;py.test'?我希望调用dev目录中的conftest.py,但不调用其他conftest.py。我在做cd开发;py.test。