Closed KrisThielemans closed 1 month ago
Note that the "other" tests use runner
@casperdcl is there an easy way to let pytest
pick up the runner
-style tests? I suppose we could follow add an AssertionError
on the number of failed tests.
In the main time, I'm going to create a work-around PR.
It's more complicated than I hoped, of course.
The reason that the "other" tests are not found is that pytest by default looks for files called test_*py
and those files are called tests_*py
.
Executing pytest src/xSTIR/pSTIR/tests/
does discover all the files, but we get 2 errors
===================================================================================================== ERRORS ======================================================================================================
__________________________________________________________________________________ ERROR at setup of test_data_container_algebra __________________________________________________________________________________
file /home/kris/devel/install/python/sirf/Utilities.py, line 591
def test_data_container_algebra(test, x, eps=1e-5):
E fixture 'test' not found
> available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
/home/kris/devel/install/python/sirf/Utilities.py:591
_________________________________________________________________________________________ ERROR at setup of test_Hessian __________________________________________________________________________________________
file /home/kris/devel/buildCondaGT/sources/SIRF/src/xSTIR/pSTIR/tests/tests_qp_lc_rdp.py, line 24
def test_Hessian(test, prior, x, eps=1e-3):
E fixture 'test' not found
> available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
/home/kris/devel/buildCondaGT/sources/SIRF/src/xSTIR/pSTIR/tests/tests_qp_lc_rdp.py:24
This is because the naming of functions.
We have https://github.com/SyneRBI/SIRF/blob/44ed35878e494f89112f11052c4828d886d4bed2/src/xSTIR/pSTIR/tests/CMakeLists.txt#L21-L26 Running it on my desktop gives
Running it manually in
sources/STIR
givesBut there are a lot of tests which are not yet unittest/pytests. Note that
test_six_adjoint.py
is picked up,presumably because it contains an(Edit: because its filename matchesAssertionError
test_*py
)Trying to run https://github.com/SyneRBI/SIRF/blob/75364cb9367da94dabca8f79cbb976fcd5eb1d3a/src/xSTIR/pSTIR/tests/test_all.py fails as its glob pattern includes the unittests.
Executing one by one flags up 2 problems: