From ed16bf4aaadd3deaedac8ee36753857b6b8a3492 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Thu, 16 Dec 2010 19:23:05 +0000 Subject: assert that the regex given to assertRegex is non-empty. --- Lib/unittest/case.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 0ad7857..6752e7a 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -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" -- cgit v0.12