diff options
Diffstat (limited to 'Lib/test/test_list.py')
-rw-r--r-- | Lib/test/test_list.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py index 5df27d3..3b94700 100644 --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -74,29 +74,31 @@ class ListTest(list_tests.CommonTest): # Userlist iterators don't support pickling yet since # they are based on generators. data = self.type2test([4, 5, 6, 7]) - it = itorg = iter(data) - d = pickle.dumps(it) - it = pickle.loads(d) - self.assertEqual(type(itorg), type(it)) - self.assertEqual(self.type2test(it), self.type2test(data)) - - it = pickle.loads(d) - next(it) - d = pickle.dumps(it) - self.assertEqual(self.type2test(it), self.type2test(data)[1:]) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + it = itorg = iter(data) + d = pickle.dumps(it, proto) + it = pickle.loads(d) + self.assertEqual(type(itorg), type(it)) + self.assertEqual(self.type2test(it), self.type2test(data)) + + it = pickle.loads(d) + next(it) + d = pickle.dumps(it, proto) + self.assertEqual(self.type2test(it), self.type2test(data)[1:]) def test_reversed_pickle(self): data = self.type2test([4, 5, 6, 7]) - it = itorg = reversed(data) - d = pickle.dumps(it) - it = pickle.loads(d) - self.assertEqual(type(itorg), type(it)) - self.assertEqual(self.type2test(it), self.type2test(reversed(data))) - - it = pickle.loads(d) - next(it) - d = pickle.dumps(it) - self.assertEqual(self.type2test(it), self.type2test(reversed(data))[1:]) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + it = itorg = reversed(data) + d = pickle.dumps(it, proto) + it = pickle.loads(d) + self.assertEqual(type(itorg), type(it)) + self.assertEqual(self.type2test(it), self.type2test(reversed(data))) + + it = pickle.loads(d) + next(it) + d = pickle.dumps(it, proto) + self.assertEqual(self.type2test(it), self.type2test(reversed(data))[1:]) def test_no_comdat_folding(self): # Issue 8847: In the PGO build, the MSVC linker's COMDAT folding |