Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed as not planned
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
More often I need to check for exact error message and do not need regular expression.
For pure convenience, this would look like.
defassertRaisesString(self, exc, string, *args, **kwargs): escaped=re.escape(string) returnself.assertRaisesRegex(exc, f'^{escaped}$', *args, **kwds)However, as using regular expression is overkill, could just add pure string case to _AssertRaisesBaseContext:
class_AssertRaisesBaseContext(_BaseTestCaseContext): def__init__(self, expected, test_case, expected_string=None, regex=True): ... class_AssertRaisesContext(_AssertRaisesBaseContext): def__exit__(self, exc_type, exc_value, tb): expected_string=self.expected_stringexc_string=str(exc_value) ifself.regex: # perform regexelse: # compare stringsHas this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Projects
Status
Done