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

Method test_filewrite

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

Source from the content-addressed store, hash-verified

533 os_helper.unlink(os_helper.TESTFN)
534
535 def test_filewrite(self):
536 a = array.array(self.typecode, 2*self.example)
537 f = open(os_helper.TESTFN, 'wb')
538 try:
539 f.write(a)
540 f.close()
541 b = array.array(self.typecode)
542 f = open(os_helper.TESTFN, 'rb')
543 b.fromfile(f, len(self.example))
544 self.assertEqual(b, array.array(self.typecode, self.example))
545 self.assertNotEqual(a, b)
546 b.fromfile(f, len(self.example))
547 self.assertEqual(a, b)
548 f.close()
549 finally:
550 if not f.closed:
551 f.close()
552 os_helper.unlink(os_helper.TESTFN)
553
554 def test_tofromlist(self):
555 a = array.array(self.typecode, 2*self.example)

Callers

nothing calls this directly

Calls 7

fromfileMethod · 0.80
assertNotEqualMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected