mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-105687: Remove deprecated objects from re
module (#105688)
This commit is contained in:
parent
fb655e0c45
commit
67f69dba0a
9 changed files with 13 additions and 56 deletions
|
@ -2398,30 +2398,6 @@ class ReTests(unittest.TestCase):
|
|||
self.assertTrue(re.fullmatch(r'(?s:(?>.*?\.).*)\Z', "a.txt")) # reproducer
|
||||
self.assertTrue(re.fullmatch(r'(?s:(?=(?P<g0>.*?\.))(?P=g0).*)\Z', "a.txt"))
|
||||
|
||||
def test_template_function_and_flag_is_deprecated(self):
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
template_re1 = re.template(r'a')
|
||||
self.assertIn('re.template()', str(cm.warning))
|
||||
self.assertIn('is deprecated', str(cm.warning))
|
||||
self.assertIn('function', str(cm.warning))
|
||||
self.assertNotIn('flag', str(cm.warning))
|
||||
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
# we deliberately use more flags here to test that that still
|
||||
# triggers the warning
|
||||
# if paranoid, we could test multiple different combinations,
|
||||
# but it's probably not worth it
|
||||
template_re2 = re.compile(r'a', flags=re.TEMPLATE|re.UNICODE)
|
||||
self.assertIn('re.TEMPLATE', str(cm.warning))
|
||||
self.assertIn('is deprecated', str(cm.warning))
|
||||
self.assertIn('flag', str(cm.warning))
|
||||
self.assertNotIn('function', str(cm.warning))
|
||||
|
||||
# while deprecated, is should still function
|
||||
self.assertEqual(template_re1, template_re2)
|
||||
self.assertTrue(template_re1.match('ahoy'))
|
||||
self.assertFalse(template_re1.match('nope'))
|
||||
|
||||
@unittest.skipIf(multiprocessing is None, 'test requires multiprocessing')
|
||||
def test_regression_gh94675(self):
|
||||
pattern = re.compile(r'(?<=[({}])(((//[^\n]*)?[\n])([\000-\040])*)*'
|
||||
|
@ -2615,11 +2591,11 @@ class PatternReprTests(unittest.TestCase):
|
|||
"re.IGNORECASE|re.DOTALL|re.VERBOSE|0x100000")
|
||||
self.assertEqual(
|
||||
repr(~re.I),
|
||||
"re.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.DOTALL|re.VERBOSE|re.TEMPLATE|re.DEBUG")
|
||||
"re.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.DOTALL|re.VERBOSE|re.DEBUG|0x1")
|
||||
self.assertEqual(repr(~(re.I|re.S|re.X)),
|
||||
"re.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.TEMPLATE|re.DEBUG")
|
||||
"re.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.DEBUG|0x1")
|
||||
self.assertEqual(repr(~(re.I|re.S|re.X|(1<<20))),
|
||||
"re.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.TEMPLATE|re.DEBUG|0xffe00")
|
||||
"re.ASCII|re.LOCALE|re.UNICODE|re.MULTILINE|re.DEBUG|0xffe01")
|
||||
|
||||
|
||||
class ImplementationTest(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue