Failure to run collected tests when rootdir changes
Closed this issue · 0 comments
buddly27 commented
When not using the BUNDLE_TESTS
mode, the pytest_discover_tests
function sometimes fails to run collected tests when the rootdir is not matching to the directory in which the function is called.
For instance, if we add a pytest.ini
file in the example directory:
touch example/pytest.ini
The tests will fail as follows:
> cmake -DCMAKE_MODULE_PATH:FILEPATH=$(pwd)/cmake -S ./example -B ./build
> cmake --build ./build
> ctest --test-dir ./build -R PythonTest.greet_world -VV
...
1: ERROR: file not found: /path/to/pytest-cmake/example/test/test/test_example.py::test_greet_world
...
This can be solved using the --rootdir
command-line option when collecting tests.