mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
#20145: assert[Raises|Warns]Regex now raise TypeError on bad regex.
Previously a non-string, non-regex second argument could cause the test to always pass. Initial patch by Kamilla Holanda.
This commit is contained in:
parent
91e7f04fc5
commit
e1b6f97dae
5 changed files with 23 additions and 1 deletions
|
@ -143,7 +143,7 @@ class _AssertRaisesBaseContext(_BaseTestCaseContext):
|
|||
self.obj_name = str(callable_obj)
|
||||
else:
|
||||
self.obj_name = None
|
||||
if isinstance(expected_regex, (bytes, str)):
|
||||
if expected_regex is not None:
|
||||
expected_regex = re.compile(expected_regex)
|
||||
self.expected_regex = expected_regex
|
||||
self.msg = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue