diff options
Diffstat (limited to 'Lib/test/test_re.py')
| -rw-r--r-- | Lib/test/test_re.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 268d66d..e4b33c9 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,7 +1,7 @@ from test.support import verbose, run_unittest import re from re import Scanner -import sys, os, traceback +import sys, traceback from weakref import proxy # Misc tests from Tim Peters' re.doc @@ -605,6 +605,27 @@ class ReTests(unittest.TestCase): self.assertEqual(next(iter).span(), (4, 4)) self.assertRaises(StopIteration, next, iter) + def test_bug_6561(self): + # '\d' should match characters in Unicode category 'Nd' + # (Number, Decimal Digit), but not those in 'Nl' (Number, + # Letter) or 'No' (Number, Other). + decimal_digits = [ + '\u0037', # '\N{DIGIT SEVEN}', category 'Nd' + '\u0e58', # '\N{THAI DIGIT SIX}', category 'Nd' + '\uff10', # '\N{FULLWIDTH DIGIT ZERO}', category 'Nd' + ] + for x in decimal_digits: + self.assertEqual(re.match('^\d$', x).group(0), x) + + not_decimal_digits = [ + '\u2165', # '\N{ROMAN NUMERAL SIX}', category 'Nl' + '\u3039', # '\N{HANGZHOU NUMERAL TWENTY}', category 'Nl' + '\u2082', # '\N{SUBSCRIPT TWO}', category 'No' + '\u32b4', # '\N{CIRCLED NUMBER THIRTY NINE}', category 'No' + ] + for x in not_decimal_digits: + self.assertIsNone(re.match('^\d$', x)) + def test_empty_array(self): # SF buf 1647541 import array @@ -727,7 +748,7 @@ class ReTests(unittest.TestCase): self.assertRaises(TypeError, _sre.compile, {}, 0, []) def run_re_tests(): - from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR + from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR if verbose: print('Running re_tests test suite') else: @@ -853,6 +874,7 @@ def run_re_tests(): if result is None: print('=== Fails on unicode-sensitive match', t) + def test_main(): run_unittest(ReTests) run_re_tests() |
