bpo-10076: Compiled regular expression and match objects now are copyable. (#1000)
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index b3b29f8..da5c953 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -971,6 +971,15 @@
# 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)