Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(85799)

Side by Side Diff: Lib/test/test_re.py

Issue 10076: Regex objects became uncopyable in 2.5
Patch Set: Created 9 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Misc/NEWS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from test.test_support import verbose, run_unittest, import_module 1 from test.test_support import verbose, run_unittest, import_module
2 import copy
2 import re 3 import re
3 from re import Scanner 4 from re import Scanner
4 import sys, traceback 5 import sys, traceback
5 from weakref import proxy 6 from weakref import proxy
6 7
7 # Misc tests from Tim Peters' re.doc 8 # Misc tests from Tim Peters' re.doc
8 9
9 # WARNING: Don't change details in these tests if you don't know 10 # WARNING: Don't change details in these tests if you don't know
10 # what you're doing. Some of these tests were carefuly modeled to 11 # what you're doing. Some of these tests were carefuly modeled to
11 # cover most of the code. 12 # cover most of the code.
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 def test_dealloc(self): 704 def test_dealloc(self):
704 # issue 3299: check for segfault in debug build 705 # issue 3299: check for segfault in debug build
705 import _sre 706 import _sre
706 # the overflow limit is different on wide and narrow builds and it 707 # the overflow limit is different on wide and narrow builds and it
707 # depends on the definition of SRE_CODE (see sre.h). 708 # depends on the definition of SRE_CODE (see sre.h).
708 # 2**128 should be big enough to overflow on both. For smaller values 709 # 2**128 should be big enough to overflow on both. For smaller values
709 # a RuntimeError is raised instead of OverflowError. 710 # a RuntimeError is raised instead of OverflowError.
710 long_overflow = 2**128 711 long_overflow = 2**128
711 self.assertRaises(TypeError, re.finditer, "a", {}) 712 self.assertRaises(TypeError, re.finditer, "a", {})
712 self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow] ) 713 self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow] )
714
715 def test_copy(self):
716 pattern1 = re.compile('a.c')
717 self.assertTrue(pattern1.match('abc'))
718 pattern2 = copy.copy(pattern1)
719 self.assertTrue(pattern2.match('abc'))
720 pattern3 = copy.deepcopy(pattern1)
721 self.assertTrue(pattern3.match('abc'))
713 722
714 def run_re_tests(): 723 def run_re_tests():
715 from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR 724 from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
716 if verbose: 725 if verbose:
717 print 'Running re_tests test suite' 726 print 'Running re_tests test suite'
718 else: 727 else:
719 # To save time, only run the first and last 10 tests 728 # To save time, only run the first and last 10 tests
720 #tests = tests[:10] + tests[-10:] 729 #tests = tests[:10] + tests[-10:]
721 pass 730 pass
722 731
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 result = obj.search(s) 843 result = obj.search(s)
835 if result is None: 844 if result is None:
836 print '=== Fails on unicode-sensitive match', t 845 print '=== Fails on unicode-sensitive match', t
837 846
838 def test_main(): 847 def test_main():
839 run_unittest(ReTests) 848 run_unittest(ReTests)
840 run_re_tests() 849 run_re_tests()
841 850
842 if __name__ == "__main__": 851 if __name__ == "__main__":
843 test_main() 852 test_main()
OLDNEW
« no previous file with comments | « no previous file | Misc/NEWS » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+