Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest configuration needs review #3393

Open
heplesser opened this issue Jan 14, 2025 · 0 comments
Open

Pytest configuration needs review #3393

heplesser opened this issue Jan 14, 2025 · 0 comments
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation.

Comments

@heplesser
Copy link
Contributor

When running make installcheck on NEST on my computer (and some others), pytest issues warnings about PytestUnknownMarkWarning:Unknown pytest.mark.skipif_missing_threads - is this a typo? even though this marker is defined in

@pytest.fixture(autouse=True)
def skipif_missing_threads(request, have_threads):
"""
Globally applied fixture that skips tests marked to be skipped when
multithreading support is missing.
"""
if not have_threads and request.node.get_closest_marker("skipif_missing_threads"):
pytest.skip("skipped because missing multithreading support.")
.

I can also reproduce this warning by running a test directly from its install location, e.g.

pytest bld/main/mpi/install/share/nest/testsuite/pytests/sli2py_other/test_multithreading.py    

If, on the other hand, I run the same test from the source code directory

pytest src/main/testsuite/pytests/sli2py_other/test_multithreading.py    

I do not get the warning. I confirmed with diff that the two testsuite directories are identical except for entirely unrelated files such as README.md.

The interesting difference is that the source directory contains pyproject.toml at the top level, which provides som pytest initialiasation:

[tool.pytest.ini_options]
markers = [
"skipif_missing_gsl: skip test if NEST was built without GSL support",
"skipif_missing_hdf5: skip test if NEST was built without HDF5 support",
"skipif_missing_mpi: skip test if NEST was built without MPI support",
"skipif_missing_threads: skip test if NEST was built without multithreading support",
"simulation: the simulation class to use. Always pass a 2nd dummy argument"
]

Indeed, copying pyproject.toml into the installed testsuite directory makes the warning disappear.

It seems wrong to my to install pyproject.toml into the installed testsuite directory just to avoid this warning. I also noticed that conftest.py contains code to insert one marker into the configuration:

See https://docs.pytest.org/en/8.0.x/how-to/mark.html.
"""
config.addinivalue_line(
"markers",
"requires_many_cores: mark tests as needing many cores (deselect with '-m \"not requires_many_cores\"')",
)

So I wonder if the material in the toml file should be moved to conftest.py or if one should find some other solution?

Test execution and skipping appears to work in spite of the warning, so I labeled this maintenance, not a bug.

@heplesser heplesser added S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation. I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation.
Projects
Status: To do
Development

No branches or pull requests

1 participant