-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Improvement to documentation of pytest.raises() match parameter. #5208
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
This passes:
|
Hi @5uper5hoot,
Definitely, thanks for pointing that out. I think we should make it explicit that Your example then becomes: >>> with pytest.raises(TypeError, match=re.escape(r'func() takes 0 positional arguments but 1 was given')):
... func(None) # succeeds
>>> |
Thanks @nicoddemus, does this sound OK?
|
Looks great, thanks! 👍 |
For pytest-dev#5208. Document explicit behavior of `match` and brief note on how to handle matching a string that may contain special re chars.
Uh oh!
There was an error while loading. Please reload this page.
The need for testing code doesn't necessarily come after the need for groking regex (at least for me it didn't). I posted this Q on Stackoverflow today and totally understand the answer, however I did spend quite a bit of time trying to wrap my head around what was going on before I was sure that I wouldn't get flamed for putting up an obvious question on SO.
As the message I'm passing to
match
is a built in error message which includes braces, and the current documentation uses the termtext or regex
, would it be considered an improvement to the documentation to note that the string that is passed tomatch
will be treated as a regex pattern, and certain special characters in the string might cause unexpected results?If so, I'd be happy to try to piece something together.
pip list
:PS C:\Users\peter_000\OneDrive\git\pytestenv> pipenv run pip list
pytest ver and os:
pytest 4.4.1, windows 10.
Example:
The text was updated successfully, but these errors were encountered: