(self)
| 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 |
no test coverage detected