Context manager - creates a file, and deletes it on __exit__.
| 520 | |
| 521 | |
| 522 | class TempFile: |
| 523 | """Context manager - creates a file, and deletes it on __exit__.""" |
| 524 | |
| 525 | def __init__(self, filename, data=b""): |
| 526 | self.filename = filename |
| 527 | self.data = data |
| 528 | |
| 529 | def __enter__(self): |
| 530 | with open(self.filename, "wb") as f: |
| 531 | f.write(self.data) |
| 532 | |
| 533 | def __exit__(self, *args): |
| 534 | unlink(self.filename) |
| 535 | |
| 536 | |
| 537 | class FileTestCase(unittest.TestCase): |
no outgoing calls
searching dependent graphs…