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

Method test_bytearray

Lib/test/pickletester.py:3055–3072  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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]

Callers

nothing calls this directly

Calls 8

opcode_in_pickleFunction · 0.85
assertIsNotMethod · 0.80
assert_is_copyMethod · 0.80
assertInMethod · 0.80
assertTrueMethod · 0.80
assertNotInMethod · 0.80
dumpsMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected