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

Method _testReadintoArray

Lib/test/test_io/test_fileio.py:114–134  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

112 self.assertEqual(n, 4)
113
114 def _testReadintoArray(self):
115 self.f.write(bytes([1, 2, 0, 255]))
116 self.f.close()
117
118 a = array('B', b'abcdefgh')
119 with self.FileIO(TESTFN, 'r') as f:
120 n = f.readinto(a)
121 self.assertEqual(a, array('B', [1, 2, 0, 255, 101, 102, 103, 104]))
122 self.assertEqual(n, 4)
123
124 a = array('b', b'abcdefgh')
125 with self.FileIO(TESTFN, 'r') as f:
126 n = f.readinto(a)
127 self.assertEqual(a, array('b', [1, 2, 0, -1, 101, 102, 103, 104]))
128 self.assertEqual(n, 4)
129
130 a = array('I', b'abcdefgh')
131 with self.FileIO(TESTFN, 'r') as f:
132 n = f.readinto(a)
133 self.assertEqual(a, array('I', b'\x01\x02\x00\xffefgh'))
134 self.assertEqual(n, 4)
135
136 def testWritelinesList(self):
137 l = [b'123', b'456']

Callers

nothing calls this directly

Calls 5

arrayClass · 0.85
writeMethod · 0.45
closeMethod · 0.45
readintoMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected