Allow pytest from project base directory#3974
Conversation
|
Note that the tests for "sas/docs/index.html" etc. in "test/system/utest_resources.py" are failing for me, but these tests also fail when using "pytest -s test" and "(cd test && pytest)", so it is outside the scope of this PR. I tried both with an edittable install "uv pip install -e ." which leaves |
|
On the linux CI environment the GUI test is executed using xvfb-run. sasview/.github/workflows/ci.yml Lines 329 to 338 in 3fcd8fb When I run the tests on linux with remote ssh login I did not set up xvfb but still the Qt tests ran to completion. I don't know if that means that the tests that render to the screen are silently ignored in my environment, or if the xvfb environment is not required for the test. I don't see anything in pyproject.toml that is setting up xvfb. |
|
I didn't see errors from Given that |
That might be the recently added |
krzywon
left a comment
There was a problem hiding this comment.
You fixed the underlying issue, but we should either modify the existing issue or create a new one outlining the behavior I'm seeing below.
python -m pytest . from the base sasview directory allows all tests to run, but with 17 failures on my end, all within the test directory.
= 17 failed, 747 passed, 5 skipped, 29 xfailed, 21 warnings in 204.14s (0:03:24) =
Running the sascalc tests separately (python -m pytest ./test) and they all pass suggesting the GUI tests are changing class variables before the calc tests can run. The exact cause will need more investigation.
= 189 passed, 2 skipped in 39.26s =
Failures from the global run:
test/sascalculator/utest_sas_gen.py::sas_gen_test::test_calculator_elements FAILED [ 78%]
test/sascalculator/utest_sas_gen.py::sas_gen_test::test_debye_impl FAILED [ 78%]
test/sascalculator/utest_sas_gen.py::sas_gen_test::test_vtkreader FAILED [ 79%]
test/sasinvariant/LinearTest.py::TestLinearFit::test_fit_covariance_fallback_on_linalg_failure FAILED [ 89%]
test/size_distribution/MaxEntTest.py::test_noRes FAILED [ 94%]
test/system/utest_resources.py::TestRecorded::test_extract_resource[_as_str] FAILED [ 97%]
test/system/utest_resources.py::TestRecorded::test_extract_resource[_as_path] FAILED [ 97%]
test/system/utest_resources.py::TestRecorded::test_extract_resource_tree[_as_str] FAILED [ 97%]
test/system/utest_resources.py::TestRecorded::test_extract_resource_tree[_as_path] FAILED [ 97%]
test/system/utest_resources.py::TestAdjacent::test_path_to_resource[_as_str] FAILED [ 97%]
test/system/utest_resources.py::TestAdjacent::test_path_to_resource[_as_path] FAILED [ 97%]
test/system/utest_resources.py::TestAdjacent::test_resource[_as_str] FAILED [ 98%]
test/system/utest_resources.py::TestAdjacent::test_resource[_as_path] FAILED [ 98%]
test/system/utest_resources.py::TestAdjacent::test_extract_resource[_as_str] FAILED [ 98%]
test/system/utest_resources.py::TestAdjacent::test_extract_resource[_as_path] FAILED [ 98%]
test/system/utest_resources.py::TestAdjacent::test_extract_resource_tree[_as_str] FAILED [ 98%]
test/system/utest_resources.py::TestAdjacent::test_extract_resource_tree[_as_path] FAILED [ 98%]
|
The tests in The cause appears to be somewhere within the logging setup that is inserted either by sasview, a qtgui test not cleaning up after itself properly, or pytest-qt itself. The tests fail Qt event loop exceptions after the actual test code has run. (obviously there's no actual Qt code involved in Excluding |
Description
Allows pytest to run from the project base directory.
The unused sas.sascalc.simulations and sas.sascalc.realspace packages are not scanned for tests.
Fixes the glob pattern to look for files with "test" or "Test" in their name. The previous version was looking for
*Test*py, which wasn't finding the utest files in the test directory on case sensitive filesystems. Instead, a secondu*pyglob pattern was introduced to find these tests, but that picks up non-test files such asutil.pyandurls.py.Fixes #3892
How Has This Been Tested?
Run
pytestfrom the base directory of the project and check that it includes both*Test*files from qtgui andutest*files from the test subdirectory. Verify that there are no errors from the tests.Review Checklist:
[if using the editor, use
[x]in place of[ ]to check a box]Documentation (check at least one)
Installers
Licensing (untick if necessary)