[Python-checkins] cpython (2.7): Test re pickling for all protocols.
serhiy.storchaka
python-checkins at python.org
Mon Sep 15 10:37:37 CEST 2014
http://hg.python.org/cpython/rev/e6c7a5a94a1d
changeset: 92431:e6c7a5a94a1d
branch: 2.7
parent: 92423:994a16b51544
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Sep 15 11:35:06 2014 +0300
summary:
Test re pickling for all protocols.
files:
Lib/test/test_re.py | 9 ++++++---
1 files changed, 6 insertions(+), 3 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
@@ -560,12 +560,15 @@
# old pickles expect the _compile() reconstructor in sre module
import_module("sre", deprecated=True)
from sre import _compile
+ # current pickle expects the _compile() reconstructor in re module
+ from re import _compile
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)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ pickled = pickle.dumps(oldpat, proto)
+ newpat = pickle.loads(pickled)
+ self.assertEqual(newpat, oldpat)
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