summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test/test_assertions.py
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-08-19 23:13:38 (GMT)
committerRobert Collins <rbtcollins@hp.com>2015-08-19 23:13:38 (GMT)
commitf01b16c1fe2c7d350ccde273fb03ac10eab35229 (patch)
treeceb8428de4a929cd715b69eb1d132afadeed9739 /Lib/unittest/test/test_assertions.py
parente4d35dc8b6fb3c071d85e2d8830566876288c180 (diff)
parentbe6caca534a6d35ccae6fe13c15eead76b721e1d (diff)
downloadcpython-f01b16c1fe2c7d350ccde273fb03ac10eab35229.zip
cpython-f01b16c1fe2c7d350ccde273fb03ac10eab35229.tar.gz
cpython-f01b16c1fe2c7d350ccde273fb03ac10eab35229.tar.bz2
Issue #20362: Honour TestCase.longMessage correctly in assertRegex.
Patch from Ilia Kurenkov.
Diffstat (limited to 'Lib/unittest/test/test_assertions.py')
-rw-r--r--Lib/unittest/test/test_assertions.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py
index c349a95..e6e2bc2 100644
--- a/Lib/unittest/test/test_assertions.py
+++ b/Lib/unittest/test/test_assertions.py
@@ -133,7 +133,6 @@ class Test_Assertions(unittest.TestCase):
try:
self.assertNotRegex('Ala ma kota', r'k.t', 'Message')
except self.failureException as e:
- self.assertIn("'kot'", e.args[0])
self.assertIn('Message', e.args[0])
else:
self.fail('assertNotRegex should have failed.')
@@ -329,6 +328,20 @@ class TestLongMessage(unittest.TestCase):
"^unexpectedly identical: None$",
"^unexpectedly identical: None : oops$"])
+ def testAssertRegex(self):
+ self.assertMessages('assertRegex', ('foo', 'bar'),
+ ["^Regex didn't match:",
+ "^oops$",
+ "^Regex didn't match:",
+ "^Regex didn't match: (.*) : oops$"])
+
+ def testAssertNotRegex(self):
+ self.assertMessages('assertNotRegex', ('foo', 'foo'),
+ ["^Regex matched:",
+ "^oops$",
+ "^Regex matched:",
+ "^Regex matched: (.*) : oops$"])
+
def assertMessagesCM(self, methodName, args, func, errors):
"""