[Python-checkins] cpython (merge 3.4 -> default): Restored re pickling test.

serhiy.storchaka python-checkins at python.org
Mon Sep 15 10:37:37 CEST 2014


http://hg.python.org/cpython/rev/49e4e3b74334
changeset:   92430:49e4e3b74334
parent:      92428:d3939f602e1f
parent:      92429:0668b3daa84e
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Sep 15 11:33:55 2014 +0300
summary:
  Restored re pickling test.

files:
  Lib/test/test_re.py |  14 +++++++++-----
  1 files changed, 9 insertions(+), 5 deletions(-)


diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -659,11 +659,15 @@
         res = re.findall(re.escape('\u2620'.encode('utf-8')), b)
         self.assertEqual(len(res), 2)
 
-    def pickle_test(self, pickle):
-        oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)')
-        s = pickle.dumps(oldpat)
-        newpat = pickle.loads(s)
-        self.assertEqual(oldpat, newpat)
+    def test_pickling(self):
+        import pickle
+        oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE)
+        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+            pickled = pickle.dumps(oldpat, proto)
+            newpat = pickle.loads(pickled)
+            self.assertEqual(newpat, oldpat)
+        # current pickle expects the _compile() reconstructor in re module
+        from re import _compile
 
     def test_constants(self):
         self.assertEqual(re.I, re.IGNORECASE)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list