MCPcopy Index your code
hub / github.com/python/cpython / check_pickle

Method check_pickle

Lib/test/test_iter.py:132–149  ·  view source on GitHub ↗
(self, itorg, seq)

Source from the content-addressed store, hash-verified

130
131 # Helper to check picklability
132 def check_pickle(self, itorg, seq):
133 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
134 d = pickle.dumps(itorg, proto)
135 it = pickle.loads(d)
136 # Cannot assert type equality because dict iterators unpickle as list
137 # iterators.
138 # self.assertEqual(type(itorg), type(it))
139 self.assertTrue(isinstance(it, collections.abc.Iterator))
140 self.assertEqual(list(it), seq)
141
142 it = pickle.loads(d)
143 try:
144 next(it)
145 except StopIteration:
146 continue
147 d = pickle.dumps(it, proto)
148 it = pickle.loads(d)
149 self.assertEqual(list(it), seq[1:])
150
151 # Test basic use of iter() function
152 def test_iter_basic(self):

Callers 2

check_iteratorMethod · 0.95
check_for_loopMethod · 0.95

Calls 5

assertTrueMethod · 0.95
assertEqualMethod · 0.95
listClass · 0.85
dumpsMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected