MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_tofrombytes

Method test_tofrombytes

Lib/test/test_array.py:532–543  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

530 self.assertEqual(a, b)
531
532 def test_tofrombytes(self):
533 a = array.array(self.typecode, 2*self.example)
534 b = array.array(self.typecode)
535 self.assertRaises(TypeError, a.tobytes, 42)
536 self.assertRaises(TypeError, b.frombytes)
537 self.assertRaises(TypeError, b.frombytes, 42)
538 b.frombytes(a.tobytes())
539 c = array.array(self.typecode, bytearray(a.tobytes()))
540 self.assertEqual(a, b)
541 self.assertEqual(a, c)
542 if a.itemsize>1:
543 self.assertRaises(ValueError, b.frombytes, b"x")
544
545 def test_fromarray(self):
546 a = array.array(self.typecode, self.example)

Callers 1

test_tofrombytesMethod · 0.45

Calls 4

assertRaisesMethod · 0.95
frombytesMethod · 0.80
tobytesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected