I'm running pytest version 6.0.1
In the root of my project I have tests/x dirs
% ls tests/x
__init__.py __pycache__ conftest.py test_x.py
conftest.py contains:
print('IN CONFTEST')
def pytest_sessionstart(session):
print('SESSIONSTART')
test_x.py contains:
def test_x():
print("X")
It appears nothing in conftest.py runs when I run pytest:
% pytest tests/x -s
=================================================================================================== test session starts ===================================================================================================
platform darwin -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: OMITTED (It's the parent of "tests")
collected 1 item
tests/x/test_x.py X
.
==================================================================================================== 1 passed in 0.01s ====================================================================================================
I'm completely stumped. I haven't found anything about anyone with an issue like this. Help!
Since I kept stumbling here, I will leave what I found and what might be your issue too:
For me, it was a basic mistake. Reading pytest doc made it clear.
I was writing my test like this:
class Test2(unittest.TestCase):
def test_new_valid_event(self, hello):
print(hello)
This did not work as 'hello', my fixture was not found. Removing the unittest.TestCase fixed it.
class Test2:
def test_new_valid_event(self, hello):
print(hello)
Pytest does not support manual loaded fixtures. Only auto ones. So please check if this is the reason for your issue.
My setup:
python -m pytest test_file.pyIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With