(self, create_data, minprotocol=0)
| 4555 | self.assertIn(expected, str(e)) |
| 4556 | |
| 4557 | def fast_save_enter(self, create_data, minprotocol=0): |
| 4558 | # gh-146059: Check that fast_save_leave() is called when |
| 4559 | # fast_save_enter() is called. |
| 4560 | if not hasattr(self, "pickler"): |
| 4561 | self.skipTest("need Pickler class") |
| 4562 | |
| 4563 | data = [create_data(i) for i in range(FAST_NESTING_LIMIT * 2)] |
| 4564 | protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1) |
| 4565 | for proto in protocols: |
| 4566 | with self.subTest(proto=proto): |
| 4567 | buf = io.BytesIO() |
| 4568 | pickler = self.pickler(buf, protocol=proto) |
| 4569 | # Enable fast mode (disables memo, enables cycle detection) |
| 4570 | pickler.fast = 1 |
| 4571 | pickler.dump(data) |
| 4572 | |
| 4573 | buf.seek(0) |
| 4574 | data2 = self.unpickler(buf).load() |
| 4575 | self.assertEqual(data2, data) |
| 4576 | |
| 4577 | def test_fast_save_enter_tuple(self): |
| 4578 | self.fast_save_enter(lambda i: (i,)) |
no test coverage detected