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