-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Implement ExceptionInfo.match() method #1502
Conversation
This implements similar functionality to unittest.TestCase.assertRegexpMatches() closes #372
Excellent! Many thanks! 😁 |
i just noticed this, we should name it i propose a matches method to just do the search and a must_match method to do the assertion |
Hmm that's a good point.
I would rather have a single one... how about just renaming it to |
well, its without a method only doing the matching it wont be possible to assert negative matches |
This is how I interpret the assert is optional. But the assert could be mandatory as well (i.e.
|
@omarkohl there is a plan for booleans that explain their cause so with pytest.raises(Exception) as excinfo:
function_to_test()
assert excinfo.matches(r'...') could generate explanations just like the current custom assertion does |
If you agree on something I'll implement it :-) |
@RonnyPfannschmidt would have to elaborate on what he means, as I'm not entirely sure myself |
@RonnyPfannschmidt does have a point that maybe the name Points to consider:
|
my personal opinion is that there should be 2 methods, one for matching, one for the commonly used assertion as for the consideration points
|
TBH I don't see much need for two methods... but I'm not against having both either. |
I don't think it's a good idea to have two methods which do the same thing, except they subtly don't 😉 I'm also okay with Also, if someone forgets the And I'm with @omarkohl here - is there really a usecase for a non-asserting |
Thanks for submitting a PR, your contribution is really appreciated!
Here's a quick checklist that should be present in PRs:
master
; for new features, targetfeatures
AUTHORS
CHANGELOG
(choose any open position to avoid merge conflicts with other PRs)