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

Method test_reverseitemiterator_pickling

Lib/test/test_dict.py:1161–1181  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1159 self.assertEqual(list(it), list(reversed(data)))
1160
1161 def test_reverseitemiterator_pickling(self):
1162 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
1163 data = {1:"a", 2:"b", 3:"c"}
1164 # dictviews aren't picklable, only their iterators
1165 itorg = reversed(data.items())
1166 d = pickle.dumps(itorg, proto)
1167 it = pickle.loads(d)
1168 # note that the type of the unpickled iterator
1169 # is not necessarily the same as the original. It is
1170 # merely an object supporting the iterator protocol, yielding
1171 # the same objects as the original one.
1172 # self.assertEqual(type(itorg), type(it))
1173 self.assertIsInstance(it, collections.abc.Iterator)
1174 self.assertEqual(dict(it), data)
1175
1176 it = pickle.loads(d)
1177 drop = next(it)
1178 d = pickle.dumps(it, proto)
1179 it = pickle.loads(d)
1180 del data[drop[0]]
1181 self.assertEqual(dict(it), data)
1182
1183 def test_reversevaluesiterator_pickling(self):
1184 for proto in range(pickle.HIGHEST_PROTOCOL + 1):

Callers

nothing calls this directly

Calls 5

assertIsInstanceMethod · 0.80
itemsMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected