mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-10076: Compiled regular expression and match objects now are copyable. (#1000)
This commit is contained in:
parent
cd85d0b90b
commit
fdbd01151d
5 changed files with 41 additions and 164 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue