From 769c2056f2ae02154d6c3eaf377f7215381491c9 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Sat, 19 Jan 2019 17:29:17 -0500 Subject: [PATCH] Improved error text of regexp assertions. --- tests/test_3141596.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_3141596.py b/tests/test_3141596.py index 3ab366a6..1cea92e8 100644 --- a/tests/test_3141596.py +++ b/tests/test_3141596.py @@ -97,8 +97,10 @@ def real_wrapper(self): class UnitTestingTestCase(DeferrableTestCase): def assertRegexContains(self, txt, expr, msg=None): - m = re.search(expr, txt, re.MULTILINE) - self.assertIsNotNone(m, msg) + if re.search(expr, txt, re.MULTILINE) is None: + self.fail("String {!r} does not contain regexp {!r}.".format( + txt, expr + )) def assertOk(self, txt, msg=None): self.assertRegexContains(txt, r'^OK', msg)