(self)
| 500 | ) |
| 501 | |
| 502 | def test_tofromfile(self): |
| 503 | a = array.array(self.typecode, 2*self.example) |
| 504 | self.assertRaises(TypeError, a.tofile) |
| 505 | os_helper.unlink(os_helper.TESTFN) |
| 506 | f = open(os_helper.TESTFN, 'wb') |
| 507 | try: |
| 508 | a.tofile(f) |
| 509 | f.close() |
| 510 | b = array.array(self.typecode) |
| 511 | f = open(os_helper.TESTFN, 'rb') |
| 512 | self.assertRaises(TypeError, b.fromfile) |
| 513 | b.fromfile(f, len(self.example)) |
| 514 | self.assertEqual(b, array.array(self.typecode, self.example)) |
| 515 | self.assertNotEqual(a, b) |
| 516 | self.assertRaises(EOFError, b.fromfile, f, len(self.example)+1) |
| 517 | self.assertEqual(a, b) |
| 518 | f.close() |
| 519 | finally: |
| 520 | if not f.closed: |
| 521 | f.close() |
| 522 | os_helper.unlink(os_helper.TESTFN) |
| 523 | |
| 524 | def test_fromfile_ioerror(self): |
| 525 | # Issue #5395: Check if fromfile raises a proper OSError |
nothing calls this directly
no test coverage detected