6
pytest 如何跨目录调用 conftest
source link: https://www.v2ex.com/t/844075
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
如何在不调整目录结构的前提下能让A
目录下的conftest.py
, 使用B
或者C
目录下的conftest.py
内的fixture
函数
# 目录结构
.
├── A
│ ├── conftest.py
│ ├── __init__.py
│ └── test_A.py
├── B
│ ├── conftest.py
│ └── __init__.py
├── C
│ ├── conftest.py
│ └── __init__.py
├── D
└── E
# ./A/conftest.py
pytest_plugins = [
"..B.conftest",
"..C.conftest"
]
$ pytest test_A.py
# 报错: ImportError: Error importing plugin "..B.conftest": No module named '.'
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK