mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
assert that the regex given to assertRegex is non-empty.
This commit is contained in:
parent
5317e9cd8d
commit
ed16bf4aaa
1 changed files with 1 additions and 0 deletions
|
@ -1121,6 +1121,7 @@ class TestCase(object):
|
|||
def assertRegex(self, text, expected_regex, msg=None):
|
||||
"""Fail the test unless the text matches the regular expression."""
|
||||
if isinstance(expected_regex, (str, bytes)):
|
||||
assert expected_regex, "expected_regex must not be empty."
|
||||
expected_regex = re.compile(expected_regex)
|
||||
if not expected_regex.search(text):
|
||||
msg = msg or "Regex didn't match"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue