diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-15 08:33:55 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-15 08:33:55 (GMT) |
commit | 884d5284f73efdab2b85bd4f9e2f66775d73ef71 (patch) | |
tree | 740f60152e5ce7b4ab6a093211d6072544fba793 /Lib | |
parent | 45759a39246938997291ff0bc8e8d995dbc98300 (diff) | |
parent | b85a97600a45bf235fd8b541ebab358f6a8aa5dd (diff) | |
download | cpython-884d5284f73efdab2b85bd4f9e2f66775d73ef71.zip cpython-884d5284f73efdab2b85bd4f9e2f66775d73ef71.tar.gz cpython-884d5284f73efdab2b85bd4f9e2f66775d73ef71.tar.bz2 |
Restored re pickling test.
Diffstat (limited to 'Lib')
-rw-r--r-- | 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 index c650f7a..011fba9 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -659,11 +659,15 @@ class ReTests(unittest.TestCase): 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) |