py.test main() invocation examples
pytest, python, unit-testing
Solution
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`
Problem
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.