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

Method test_tofromfile

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

Source from the content-addressed store, hash-verified

468 )
469
470 def test_tofromfile(self):
471 a = array.array(self.typecode, 2*self.example)
472 self.assertRaises(TypeError, a.tofile)
473 os_helper.unlink(os_helper.TESTFN)
474 f = open(os_helper.TESTFN, 'wb')
475 try:
476 a.tofile(f)
477 f.close()
478 b = array.array(self.typecode)
479 f = open(os_helper.TESTFN, 'rb')
480 self.assertRaises(TypeError, b.fromfile)
481 b.fromfile(f, len(self.example))
482 self.assertEqual(b, array.array(self.typecode, self.example))
483 self.assertNotEqual(a, b)
484 self.assertRaises(EOFError, b.fromfile, f, len(self.example)+1)
485 self.assertEqual(a, b)
486 f.close()
487 finally:
488 if not f.closed:
489 f.close()
490 os_helper.unlink(os_helper.TESTFN)
491
492 def test_fromfile_ioerror(self):
493 # Issue #5395: Check if fromfile raises a proper OSError

Callers 1

test_tofromfileMethod · 0.45

Calls 9

assertRaisesMethod · 0.95
lenFunction · 0.85
tofileMethod · 0.80
assertNotEqualMethod · 0.80
openFunction · 0.50
unlinkMethod · 0.45
closeMethod · 0.45
fromfileMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected