diff --git a/testtools/matchers.py b/testtools/matchers.py index 1c40d41..c75867d 100644 --- a/testtools/matchers.py +++ b/testtools/matchers.py @@ -730,7 +730,8 @@ class MatchesRegex(object): def match(self, value): if not re.match(self.pattern, value, self.flags): - return Mismatch("%r does not match %r" % (value, self.pattern)) + return Mismatch("%r does not match /%s/" % ( + value, self.pattern)) class MatchesSetwise(object): diff --git a/testtools/tests/test_matchers.py b/testtools/tests/test_matchers.py index d17a053..a8a9402 100644 --- a/testtools/tests/test_matchers.py +++ b/testtools/tests/test_matchers.py @@ -258,7 +258,7 @@ class TestMatchesExceptionTypeReInterface(TestCase, TestMatchersInterface): MatchesException(Exception, 'fo.')) ] describe_examples = [ - ("'bar' does not match 'fo.'", + ("'bar' does not match /fo./", error_bar, MatchesException(ValueError, "fo.")), ] @@ -639,7 +639,8 @@ class TestMatchesRegex(TestCase, TestMatchersInterface): ] describe_examples = [ - ("'c' does not match 'a|b'", 'c', MatchesRegex('a|b')), + ("'c' does not match /a|b/", 'c', MatchesRegex('a|b')), + ("'c' does not match /a\d/", 'c', MatchesRegex(r'a\d')), ] diff --git a/testtools/tests/test_with_with.py b/testtools/tests/test_with_with.py index 23ce203..e06adeb 100644 --- a/testtools/tests/test_with_with.py +++ b/testtools/tests/test_with_with.py @@ -32,7 +32,7 @@ class TestExpectedException(TestCase): raise ValueError('mismatch') except AssertionError: e = sys.exc_info()[1] - self.assertEqual("'mismatch' does not match 'tes.'", str(e)) + self.assertEqual("'mismatch' does not match /tes./", str(e)) else: self.fail('AssertionError not raised.')