summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-12-15 12:06:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-12-15 12:06:02 (GMT)
commit65ee4674e290ba893509f51f192dd1c9aa3a0422 (patch)
treec1e960162df4444ff18a2ad3aff11d713ef9ea12 /Lib/test/test_builtin.py
parent0e32ea1089059a15b04a40c43bfe671e38ae16e7 (diff)
parentbad1257c96943dcb39584a41e1a178542479df97 (diff)
downloadcpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.zip
cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.gz
cpython-65ee4674e290ba893509f51f192dd1c9aa3a0422.tar.bz2
Issue #22777: Test pickling with all protocols.
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index c78fce0..6166da5 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -121,9 +121,9 @@ def map_char(arg):
class BuiltinTest(unittest.TestCase):
# Helper to check picklability
- def check_iter_pickle(self, it, seq):
+ def check_iter_pickle(self, it, seq, proto):
itorg = it
- d = pickle.dumps(it)
+ d = pickle.dumps(it, proto)
it = pickle.loads(d)
self.assertEqual(type(itorg), type(it))
self.assertEqual(list(it), seq)
@@ -134,7 +134,7 @@ class BuiltinTest(unittest.TestCase):
next(it)
except StopIteration:
return
- d = pickle.dumps(it)
+ d = pickle.dumps(it, proto)
it = pickle.loads(d)
self.assertEqual(list(it), seq[1:])
@@ -636,9 +636,10 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, list, filter(42, (1, 2)))
def test_filter_pickle(self):
- f1 = filter(filter_char, "abcdeabcde")
- f2 = filter(filter_char, "abcdeabcde")
- self.check_iter_pickle(f1, list(f2))
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ f1 = filter(filter_char, "abcdeabcde")
+ f2 = filter(filter_char, "abcdeabcde")
+ self.check_iter_pickle(f1, list(f2), proto)
def test_getattr(self):
self.assertTrue(getattr(sys, 'stdout') is sys.stdout)
@@ -834,9 +835,10 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(RuntimeError, list, map(badfunc, range(5)))
def test_map_pickle(self):
- m1 = map(map_char, "Is this the real life?")
- m2 = map(map_char, "Is this the real life?")
- self.check_iter_pickle(m1, list(m2))
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ m1 = map(map_char, "Is this the real life?")
+ m2 = map(map_char, "Is this the real life?")
+ self.check_iter_pickle(m1, list(m2), proto)
def test_max(self):
self.assertEqual(max('123123'), '3')
@@ -1433,8 +1435,9 @@ class BuiltinTest(unittest.TestCase):
a = (1, 2, 3)
b = (4, 5, 6)
t = [(1, 4), (2, 5), (3, 6)]
- z1 = zip(a, b)
- self.check_iter_pickle(z1, t)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ z1 = zip(a, b)
+ self.check_iter_pickle(z1, t, proto)
def test_format(self):
# Test the basic machinery of the format() builtin. Don't test