Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed16bf4

Browse files
committed
assert that the regex given to assertRegex is non-empty.
1 parent 5317e9c commit ed16bf4

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

Lib/unittest/case.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ def assertWarnsRegex(self, expected_warning, expected_regex,
11211121
def assertRegex(self, text, expected_regex, msg=None):
11221122
"""Fail the test unless the text matches the regular expression."""
11231123
if isinstance(expected_regex, (str, bytes)):
1124+
assert expected_regex, "expected_regex must not be empty."
11241125
expected_regex = re.compile(expected_regex)
11251126
if not expected_regex.search(text):
11261127
msg = msg or "Regex didn't match"

0 commit comments

Comments
 (0)