bpo-10076: Compiled regular expression and match objects now are copyable. (#1000)

This commit is contained in:
Serhiy Storchaka 2017-04-16 10:16:03 +03:00 committed by GitHub
parent cd85d0b90b
commit fdbd01151d
5 changed files with 41 additions and 164 deletions

View file

@ -971,6 +971,15 @@ class ReTests(unittest.TestCase):
# current pickle expects the _compile() reconstructor in re module
from re import _compile
def test_copying(self):
import copy
p = re.compile(r'(?P<int>\d+)(?:\.(?P<frac>\d*))?')
self.assertIs(copy.copy(p), p)
self.assertIs(copy.deepcopy(p), p)
m = p.match('12.34')
self.assertIs(copy.copy(m), m)
self.assertIs(copy.deepcopy(m), m)
def test_constants(self):
self.assertEqual(re.I, re.IGNORECASE)
self.assertEqual(re.L, re.LOCALE)