Reputation: 519
I have this structure.
/bin
__init__.py
run_test.py (call pytest.main)
/tests
__init__.py
test_xyz.py
If I call run_test.py using simply via pytest.main(), it won't invoke tests in "tests" module. I tried passing couple of parameters like module="tests" etc but they don't work. I have to altogether chuck auto discovery and use the suite parameter for it to pick up any tests.
What am I missing? I tried to walk through the code in the pytest module, but it is way too complex to understand. And the documentation is very bad.
Upvotes: 5
Views: 11124
Reputation: 854
I know it's later answer. I hope it could help somebody in the future.
It's better to have run_test.py
in root project dir, I mean you would move out run_test.py
from /bin
to one higher level project structure.
Upvotes: 0
Reputation: 1450
You can pass the full path of what to execute.
import pytest
pytest_args = [
'/tests',
# other tests here...
]
pytest.main(pytest_args)
This will execute all the tests found in the directory,
there is no need to have /tests/__init__.py
Upvotes: 3