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

Method test_readinto1_array

Lib/test/test_io.py:1598–1617  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1596 self.assertEqual(bm[n:], b'x' * (len(bm[n:])))
1597
1598 def test_readinto1_array(self):
1599 buffer_size = 60
1600 data = b"a" * 26
1601 rawio = self.MockRawIO((data,))
1602 bufio = self.tp(rawio, buffer_size=buffer_size)
1603
1604 # Create an array with element size > 1 byte
1605 b = array.array('i', b'x' * 32)
1606 assert len(b) != 16
1607
1608 # Read into it. We should get as many *bytes* as we can fit into b
1609 # (which is more than the number of elements)
1610 n = bufio.readinto1(b)
1611 self.assertGreater(n, len(b))
1612
1613 # Check that old contents of b are preserved
1614 bm = memoryview(b).cast('B')
1615 self.assertLess(n, len(bm))
1616 self.assertEqual(bm[:n], data[:n])
1617 self.assertEqual(bm[n:], b'x' * (len(bm[n:])))
1618
1619 def test_readlines(self):
1620 def bufio():

Callers

nothing calls this directly

Calls 6

lenFunction · 0.85
assertGreaterMethod · 0.80
readinto1Method · 0.45
castMethod · 0.45
assertLessMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected