Skip to content

silx.test.run_tests: Updated usage of pytest #4330

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

t20100
Copy link
Member

@t20100 t20100 commented May 19, 2025

Checklist:


Merge PR #4324 first!

This PR reworks the config of pytest regarding warnings.
It moves the configuration of warning raising an error/being ignored from silx.test.run_tests to the project's conftest.py by using the pytest_collection_modifyitems hook.
This allows using the same rules no matter how the tests are run (pytest or silx.test.run_tests).

@t20100 t20100 added this to the Next major release milestone May 19, 2025
@t20100 t20100 requested a review from kif May 19, 2025 12:59
Comment on lines +84 to +89
def pytest_collection_modifyitems(items):
"""Add warnings filters to all tests"""
for item in items:
for filter_string in _FILTERWARNINGS:
item.add_marker(pytest.mark.filterwarnings(filter_string))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the only way I found to set fiterwarnings for all tests without relying on the source project containing a pytest.ini or pyproject.toml config (not an option to allow running tests from an installed package.

Alternatives:

  • Embedding pytest.ini in the Python package and use it from silx.test.run_tests.
  • Use pytestmark, but it needs to be set in all test modules...

@t20100 t20100 force-pushed the update-pytest branch 2 times, most recently from 421447c to 95dd666 Compare May 19, 2025 15:32
@t20100 t20100 marked this pull request as draft May 20, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant