]> granicus.if.org Git - python/commitdiff
Added tests for qualified sub and split
authorGuido van Rossum <guido@python.org>
Wed, 14 Jan 1998 16:42:17 +0000 (16:42 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 14 Jan 1998 16:42:17 +0000 (16:42 +0000)
Lib/test/test_re.py

index 99263b83da60dff1650ff27ac33183cc00a1eb8a..b47c1059f8d4a4675e328afe5ed77f2b8942081d 100644 (file)
@@ -38,6 +38,12 @@ try:
 except AssertionError:
     raise TestFailed, "re.sub"
 
+try:
+    assert re.sub('a', 'b', 'aaaaa') == 'bbbbb'
+    assert re.sub('a', 'b', 'aaaaa', 1) == 'baaaa'
+except AssertionError:
+    raise TestFailed, "qualified re.sub"
+
 if verbose:
     print 'Running tests on symbolic references'
 
@@ -115,6 +121,15 @@ try:
 except AssertionError:
     raise TestFailed, "re.split"
 
+try:
+    assert re.split(":", ":a:b::c", 2) == ['', 'a', 'b::c']
+    assert re.split(':', 'a:b:c:d', 2) == ['a', 'b', 'c:d']
+
+    assert re.split("(:)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']
+    assert re.split("(:*)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']    
+except AssertionError:
+    raise TestFailed, "qualified re.split"
+
 if verbose:
     print 'Pickling a RegexObject instance'
     import pickle