diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 5406a2891bb..dc44e506b1d 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1119,12 +1119,12 @@ class CommonBufferedTests: def test_repr(self): raw = self.MockRawIO() b = self.tp(raw) - clsname = "%s.%s" % (self.tp.__module__, self.tp.__qualname__) - self.assertEqual(repr(b), "<%s>" % clsname) + clsname = r"(%s\.)?%s" % (self.tp.__module__, self.tp.__qualname__) + self.assertRegex(repr(b), "<%s>" % clsname) raw.name = "dummy" - self.assertEqual(repr(b), "<%s name='dummy'>" % clsname) + self.assertRegex(repr(b), "<%s name='dummy'>" % clsname) raw.name = b"dummy" - self.assertEqual(repr(b), "<%s name=b'dummy'>" % clsname) + self.assertRegex(repr(b), "<%s name=b'dummy'>" % clsname) def test_recursive_repr(self): # Issue #25455 @@ -2598,17 +2598,17 @@ class TextIOWrapperTest(unittest.TestCase): b = self.BufferedReader(raw) t = self.TextIOWrapper(b, encoding="utf-8") modname = self.TextIOWrapper.__module__ - self.assertEqual(repr(t), - "<%s.TextIOWrapper encoding='utf-8'>" % modname) + self.assertRegex(repr(t), + r"<(%s\.)?TextIOWrapper encoding='utf-8'>" % modname) raw.name = "dummy" - self.assertEqual(repr(t), - "<%s.TextIOWrapper name='dummy' encoding='utf-8'>" % modname) + self.assertRegex(repr(t), + r"<(%s\.)?TextIOWrapper name='dummy' encoding='utf-8'>" % modname) t.mode = "r" - self.assertEqual(repr(t), - "<%s.TextIOWrapper name='dummy' mode='r' encoding='utf-8'>" % modname) + self.assertRegex(repr(t), + r"<(%s\.)?TextIOWrapper name='dummy' mode='r' encoding='utf-8'>" % modname) raw.name = b"dummy" - self.assertEqual(repr(t), - "<%s.TextIOWrapper name=b'dummy' mode='r' encoding='utf-8'>" % modname) + self.assertRegex(repr(t), + r"<(%s\.)?TextIOWrapper name=b'dummy' mode='r' encoding='utf-8'>" % modname) t.buffer.detach() repr(t) # Should not raise an exception @@ -4174,11 +4174,11 @@ class CMiscIOTest(MiscIOTest): err = res.err.decode() if res.rc != 0: # Failure: should be a fatal error - self.assertIn("Fatal Python error: could not acquire lock " - "for <_io.BufferedWriter name='<{stream_name}>'> " - "at interpreter shutdown, possibly due to " - "daemon threads".format_map(locals()), - err) + pattern = (r"Fatal Python error: could not acquire lock " + r"for <(_io\.)?BufferedWriter name='<{stream_name}>'> " + r"at interpreter shutdown, possibly due to " + r"daemon threads".format_map(locals())) + self.assertRegex(err, pattern) else: self.assertFalse(err.strip('.!')) diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 0a77e6fe9ed..137c31de59a 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1761,24 +1761,28 @@ class ReTests(unittest.TestCase): def test_match_repr(self): for string in '[abracadabra]', S('[abracadabra]'): m = re.search(r'(.+)(.*?)\1', string) - self.assertEqual(repr(m), "<%s.%s object; " - "span=(1, 12), match='abracadabra'>" % - (type(m).__module__, type(m).__qualname__)) + pattern = r"<(%s\.)?%s object; span=\(1, 12\), match='abracadabra'>" % ( + type(m).__module__, type(m).__qualname__ + ) + self.assertRegex(repr(m), pattern) for string in (b'[abracadabra]', B(b'[abracadabra]'), bytearray(b'[abracadabra]'), memoryview(b'[abracadabra]')): m = re.search(br'(.+)(.*?)\1', string) - self.assertEqual(repr(m), "<%s.%s object; " - "span=(1, 12), match=b'abracadabra'>" % - (type(m).__module__, type(m).__qualname__)) + pattern = r"<(%s\.)?%s object; span=\(1, 12\), match=b'abracadabra'>" % ( + type(m).__module__, type(m).__qualname__ + ) + self.assertRegex(repr(m), pattern) first, second = list(re.finditer("(aa)|(bb)", "aa bb")) - self.assertEqual(repr(first), "<%s.%s object; " - "span=(0, 2), match='aa'>" % - (type(second).__module__, type(first).__qualname__)) - self.assertEqual(repr(second), "<%s.%s object; " - "span=(3, 5), match='bb'>" % - (type(second).__module__, type(second).__qualname__)) + pattern = r"<(%s\.)?%s object; span=\(0, 2\), match='aa'>" % ( + type(second).__module__, type(second).__qualname__ + ) + self.assertRegex(repr(first), pattern) + pattern = r"<(%s\.)?%s object; span=\(3, 5\), match='bb'>" % ( + type(second).__module__, type(second).__qualname__ + ) + self.assertRegex(repr(second), pattern) def test_zerowidth(self): # Issues 852532, 1647489, 3262, 25054. diff --git a/Misc/ACKS b/Misc/ACKS index 87107b9cfc7..6b1fdbc37fa 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -143,6 +143,7 @@ Michel Van den Bergh Julian Berman Brice Berna Olivier Bernard +Maxwell Bernstein Eric Beser Steven Bethard Stephen Bevan