Restored re pickling test.

This commit is contained in:
Serhiy Storchaka 2014-09-15 11:33:19 +03:00
parent ad24d62882
commit b85a97600a
1 changed files with 9 additions and 5 deletions

View File

@ -659,11 +659,15 @@ class ReTests(unittest.TestCase):
res = re.findall(re.escape('\u2620'.encode('utf-8')), b) res = re.findall(re.escape('\u2620'.encode('utf-8')), b)
self.assertEqual(len(res), 2) self.assertEqual(len(res), 2)
def pickle_test(self, pickle): def test_pickling(self):
oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)') import pickle
s = pickle.dumps(oldpat) oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE)
newpat = pickle.loads(s) for proto in range(pickle.HIGHEST_PROTOCOL + 1):
self.assertEqual(oldpat, newpat) 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): def test_constants(self):
self.assertEqual(re.I, re.IGNORECASE) self.assertEqual(re.I, re.IGNORECASE)