(self)
| 1103 | self.assertEqual(list(it), list(data)) |
| 1104 | |
| 1105 | def test_itemiterator_pickling(self): |
| 1106 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 1107 | data = {1:"a", 2:"b", 3:"c"} |
| 1108 | # dictviews aren't picklable, only their iterators |
| 1109 | itorg = iter(data.items()) |
| 1110 | d = pickle.dumps(itorg, proto) |
| 1111 | it = pickle.loads(d) |
| 1112 | # note that the type of the unpickled iterator |
| 1113 | # is not necessarily the same as the original. It is |
| 1114 | # merely an object supporting the iterator protocol, yielding |
| 1115 | # the same objects as the original one. |
| 1116 | # self.assertEqual(type(itorg), type(it)) |
| 1117 | self.assertIsInstance(it, collections.abc.Iterator) |
| 1118 | self.assertEqual(dict(it), data) |
| 1119 | |
| 1120 | it = pickle.loads(d) |
| 1121 | drop = next(it) |
| 1122 | d = pickle.dumps(it, proto) |
| 1123 | it = pickle.loads(d) |
| 1124 | del data[drop[0]] |
| 1125 | self.assertEqual(dict(it), data) |
| 1126 | |
| 1127 | def test_valuesiterator_pickling(self): |
| 1128 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
nothing calls this directly
no test coverage detected