-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Make assertion rewrite warning messages filterable #13429
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
Make assertion rewrite warning messages filterable #13429
Conversation
so it can be filtered using standard Python warning filters.
nicoddemus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, simple and to the point! Thanks @ikappaki!
|
Arent other regex matches avaliable to match? |
|
The issue is that the string passed to the -W command line option is treated as a literal, so regex characters have no effect: i.e., in CPython, the |
|
So we should aim for warning filters in pytest settings instead of using slightly off characters in the long run |
You OK to merge the PR or would you like to hold it off to discuss it further? |
|
Let's merge it for now But eventually id like to be able to block the warnings properly |
…-dev#13429) This makes it possible to filter them using standard Python warning filters. --- Co-authored-by: ikappaki <[email protected]>
Hi, can you please consider patch to suppress the pytest rewrite assertion warning when running `basilisp test`. It fixes #1252. I haven’t added a test, as it would require creating a virtual environment during testing, which seemed excessive for this issue. However, I’m happy to add one if you feel it’s necessary. Thanks Note: this is a follow up to #1255 but it uses the `;` separator to specify the module name, introduced by pytest-dev/pytest#13429 in [Pytest 8.4.0](https://docs.pytest.org/en/stable/changelog.html#pytest-8-4-0-2025-06-02). --------- Co-authored-by: ikappaki <[email protected]>

Hi,
can you please consider patch to mare assertion rewrite warning messages filterable using the standard
-Woption. It addresses #5473.The issue arises when a Python package defines a
pytestplugin, and also callspytest.main()programmatically, after importing one of its own submodules. Because the module is already imported,pytest.main()cannot rewrite its assertions and emits a warning like:Module already imported so cannot be rewritten: basilispUnfortunately, the
:in the message conflicts with Python’s warning filter syntax, where:is used as a delimiter. This prevents users from filtering out the warning via-W.This patch replaces the
:in the warning message with a;, making it possible to write a valid warning filter like:-W ignore:Module already imported so cannot be rewritten; mymodule:pytest.PytestAssertRewriteWarningWe believe there's no need to force assertion rewriting simply because a module defines a plugin, and users should be able to suppress this warning when needed.
For background and alternative solutions considered, see #5473 (comment).
Happy to discuss further or consider alternatives.
changelogfolderThanks