(self, create_nested,
minprotocol=0, compare_equal=True,
depth=FAST_NESTING_LIMIT * 2)
| 4595 | self.fast_save_enter(lambda i: {"key": i}) |
| 4596 | |
| 4597 | def deep_nested_struct(self, create_nested, |
| 4598 | minprotocol=0, compare_equal=True, |
| 4599 | depth=FAST_NESTING_LIMIT * 2): |
| 4600 | # gh-146059: Check that fast_save_leave() is called when |
| 4601 | # fast_save_enter() is called. |
| 4602 | if not hasattr(self, "pickler"): |
| 4603 | self.skipTest("need Pickler class") |
| 4604 | |
| 4605 | data = None |
| 4606 | for i in range(depth): |
| 4607 | data = create_nested(data) |
| 4608 | protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1) |
| 4609 | for proto in protocols: |
| 4610 | with self.subTest(proto=proto): |
| 4611 | buf = io.BytesIO() |
| 4612 | pickler = self.pickler(buf, protocol=proto) |
| 4613 | # Enable fast mode (disables memo, enables cycle detection) |
| 4614 | pickler.fast = 1 |
| 4615 | pickler.dump(data) |
| 4616 | |
| 4617 | buf.seek(0) |
| 4618 | data2 = self.unpickler(buf).load() |
| 4619 | if compare_equal: |
| 4620 | self.assertEqual(data2, data) |
| 4621 | |
| 4622 | def test_deep_nested_struct_tuple(self): |
| 4623 | self.deep_nested_struct(lambda data: (data,)) |
no test coverage detected