(self)
| 3053 | self.assert_is_copy(expected, self.loads(p)) |
| 3054 | |
| 3055 | def test_bytearray(self): |
| 3056 | for proto in protocols: |
| 3057 | for s in b'', b'xyz', b'xyz'*100: |
| 3058 | b = bytearray(s) |
| 3059 | p = self.dumps(b, proto) |
| 3060 | bb = self.loads(p) |
| 3061 | self.assertIsNot(bb, b) |
| 3062 | self.assert_is_copy(b, bb) |
| 3063 | if proto <= 3: |
| 3064 | # bytearray is serialized using a global reference |
| 3065 | self.assertIn(b'bytearray', p) |
| 3066 | self.assertTrue(opcode_in_pickle(pickle.GLOBAL, p)) |
| 3067 | elif proto == 4: |
| 3068 | self.assertIn(b'bytearray', p) |
| 3069 | self.assertTrue(opcode_in_pickle(pickle.STACK_GLOBAL, p)) |
| 3070 | elif proto == 5: |
| 3071 | self.assertNotIn(b'bytearray', p) |
| 3072 | self.assertTrue(opcode_in_pickle(pickle.BYTEARRAY8, p)) |
| 3073 | |
| 3074 | def test_bytearray_memoization(self): |
| 3075 | array_types = [bytearray] |
nothing calls this directly
no test coverage detected