| 427 | self.assertEqual(xflByte, expectedXflByte) |
| 428 | |
| 429 | def test_with_open(self): |
| 430 | # GzipFile supports the context management protocol |
| 431 | with gzip.GzipFile(self.filename, "wb") as f: |
| 432 | f.write(b"xxx") |
| 433 | f = gzip.GzipFile(self.filename, "rb") |
| 434 | f.close() |
| 435 | try: |
| 436 | with f: |
| 437 | pass |
| 438 | except ValueError: |
| 439 | pass |
| 440 | else: |
| 441 | self.fail("__enter__ on a closed file didn't raise an exception") |
| 442 | try: |
| 443 | with gzip.GzipFile(self.filename, "wb") as f: |
| 444 | 1/0 |
| 445 | except ZeroDivisionError: |
| 446 | pass |
| 447 | else: |
| 448 | self.fail("1/0 didn't raise an exception") |
| 449 | |
| 450 | def test_zero_padded_file(self): |
| 451 | with gzip.GzipFile(self.filename, "wb") as f: |