| 476 | self.assertEqual(xlines, [b'Test']) |
| 477 | |
| 478 | def testContextProtocol(self): |
| 479 | with BZ2File(self.filename, "wb") as f: |
| 480 | f.write(b"xxx") |
| 481 | f = BZ2File(self.filename, "rb") |
| 482 | f.close() |
| 483 | try: |
| 484 | with f: |
| 485 | pass |
| 486 | except ValueError: |
| 487 | pass |
| 488 | else: |
| 489 | self.fail("__enter__ on a closed file didn't raise an exception") |
| 490 | try: |
| 491 | with BZ2File(self.filename, "wb") as f: |
| 492 | 1/0 |
| 493 | except ZeroDivisionError: |
| 494 | pass |
| 495 | else: |
| 496 | self.fail("1/0 didn't raise an exception") |
| 497 | |
| 498 | @threading_helper.requires_working_threading() |
| 499 | def testThreading(self): |