| 486 | self.assertEqual(xlines, [b'Test']) |
| 487 | |
| 488 | def testContextProtocol(self): |
| 489 | with BZ2File(self.filename, "wb") as f: |
| 490 | f.write(b"xxx") |
| 491 | f = BZ2File(self.filename, "rb") |
| 492 | f.close() |
| 493 | try: |
| 494 | with f: |
| 495 | pass |
| 496 | except ValueError: |
| 497 | pass |
| 498 | else: |
| 499 | self.fail("__enter__ on a closed file didn't raise an exception") |
| 500 | try: |
| 501 | with BZ2File(self.filename, "wb") as f: |
| 502 | 1/0 |
| 503 | except ZeroDivisionError: |
| 504 | pass |
| 505 | else: |
| 506 | self.fail("1/0 didn't raise an exception") |
| 507 | |
| 508 | @threading_helper.requires_working_threading() |
| 509 | def testThreading(self): |