summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/unittest.rst6
-rw-r--r--Lib/unittest/case.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index b5b23c7..19c8b0b 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -903,9 +903,9 @@ Test cases
.. method:: assertNotRegexpMatches(text, regexp, msg=None)
Verifies that a *regexp* search does not match *text*. Fails with an error
- message including the pattern and the *text*. *regexp* may be
- a regular expression object or a string containing a regular expression
- suitable for use by :func:`re.search`.
+ message including the pattern and the part of *text* that matches. *regexp*
+ may be a regular expression object or a string containing a regular
+ expression suitable for use by :func:`re.search`.
.. versionadded:: 3.2
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 366fe87..cbe8dcb 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -993,6 +993,7 @@ class TestCase(object):
callable_obj(*args, **kwargs)
def assertRegexpMatches(self, text, expected_regexp, msg=None):
+ """Fail the test unless the text matches the regular expression."""
if isinstance(expected_regexp, (str, bytes)):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(text):
@@ -1001,6 +1002,7 @@ class TestCase(object):
raise self.failureException(msg)
def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
+ """Fail the test if the text matches the regular expression."""
if isinstance(unexpected_regexp, (str, bytes)):
unexpected_regexp = re.compile(unexpected_regexp)
match = unexpected_regexp.search(text)