-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Exclude some test modules from assertion rewriting #2203
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
Comments
I don't think this would help with #2180 though, would it? I suppose we'd still need to use |
@The-Compiler you're right. 😁 |
From #743, there's an undocumented |
My use case is a pytest plugin that manages its own assertion messages: https://github.com/jacebrowning/pytest-expecter |
FWIW this is now on the reference page. 😉 |
Would be cool if there's a flag to always disable rewrite. |
@laike9m |
Ah interesting. Found that in the documentation. Thanks! https://docs.pytest.org/en/latest/assert.html#disabling-assert-rewriting |
Sometimes users do some "black magic" like patching builtins (for example #2180) and that might completely break pytest.
While of course we should not encourage too much black magic, I was wondering if we could alleviate the problem for users which don't want or can't change their tests to disable assertion rewriting for some of the test modules.
I was thinking of something like the
# encoding
comment used by Python to declare the encoding of a file. An alternative would be to list some test files onpytest.ini
, but I think the comment is better because it is written in the file itself, rather than far away from it.How about
# pytest-no-rewrite
or something like this?The text was updated successfully, but these errors were encountered: