Reputation: 329
I have the following directory structure in my directory
tests
|
|__A
| |__test_1.py
|__B
| |__test_2.py
|__C
| |__test3.py
|__D
| |__test4.py
|__test_setup
| |__conftest.py
|__pytest.ini
so my pytest.ini looks like follows
[pytest]
confcutdir = tests/test_setup/
rootdir = tests/test_setup
SO my question here is I want pytest to look into tests/test_setup for conftest.py One option is to keep conftest.py at tests directory level (that's not a good option)
when I try to run:
py.test --multihost-config=test.yaml test_1.py -q -s
it fails to load conftest.py which has a bunch of fixtures.
Am I doing it right or my pytest.ini is screwed up?
Please suggest. Thanks in advance
Upvotes: 3
Views: 2257
Reputation:
conftests are local plugins for certain directories
if you want to use them in a different fashion, you need to create plugins and reference them as plugins you want to use
(plugins can be just python modules you name in local contests)
in general you should NEVER import a fixture
because each import site is considered a new fixture (even for session scope)
instead you should declare modules that contain fixtures
Upvotes: 2