]> granicus.if.org Git - python/commitdiff
Check in a testcase for SF bug #449000: re.sub(r'\n', ...) broke.
authorGuido van Rossum <guido@python.org>
Fri, 10 Aug 2001 14:52:48 +0000 (14:52 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 10 Aug 2001 14:52:48 +0000 (14:52 +0000)
Lib/test/test_re.py
Lib/test/test_sre.py

index f4c5cb889151e7b925cbb11f7fbb07abda769215..45bb3b14ec7c0c7189451f36deda3ab788545950 100644 (file)
@@ -59,6 +59,12 @@ try:
     verify(re.sub('a', '\t\n\v\r\f\a', 'a') == (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)))
 
     verify(re.sub('^\s*', 'X', 'test') == 'Xtest')
+
+    # Test for sub() on escaped characters, see SF bug #449000
+    verify(re.sub(r'\r\n', r'\n', 'abc\r\ndef\r\n') == 'abc\ndef\n')
+    verify(re.sub('\r\n', r'\n', 'abc\r\ndef\r\n') == 'abc\ndef\n')
+    verify(re.sub(r'\r\n', '\n', 'abc\r\ndef\r\n') == 'abc\ndef\n')
+    verify(re.sub('\r\n', '\n', 'abc\r\ndef\r\n') == 'abc\ndef\n')
 except AssertionError:
     raise TestFailed, "re.sub"
 
index e266d14d5ef7420c8ff7fd290939a0478ec4ff97..f673c339fe9943bd8a48768e535ec7c9f2b0d5bb 100644 (file)
@@ -117,6 +117,12 @@ test(r"""sre.sub(r'a', 'b', 'aaaaa', 1)""", 'baaaa')
 # bug 114660
 test(r"""sre.sub(r'(\S)\s+(\S)', r'\1 \2', 'hello  there')""", 'hello there')
 
+# Test for sub() on escaped characters, see SF bug #449000
+test(r"""sre.sub(r'\r\n', r'\n', 'abc\r\ndef\r\n')""", 'abc\ndef\n')
+test(r"""sre.sub('\r\n', r'\n', 'abc\r\ndef\r\n')""", 'abc\ndef\n')
+test(r"""sre.sub(r'\r\n', '\n', 'abc\r\ndef\r\n')""", 'abc\ndef\n')
+test(r"""sre.sub('\r\n', '\n', 'abc\r\ndef\r\n')""", 'abc\ndef\n')
+
 if verbose:
     print 'Running tests on symbolic references'