From: Serhiy Storchaka Date: Mon, 15 Sep 2014 08:35:06 +0000 (+0300) Subject: Test re pickling for all protocols. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=038fac67c02d85df2d34f1092a51db31f758bb63;p=python Test re pickling for all protocols. --- diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index f285c6bed2..88eafc99a5 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -560,12 +560,15 @@ class ReTests(unittest.TestCase): # 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)