| 516 | turtle.TurtleScreen.save(screen, os.path.join(parent, "a.ps")) |
| 517 | |
| 518 | def test_save_raises_if_file_found(self) -> None: |
| 519 | screen = unittest.mock.Mock() |
| 520 | |
| 521 | with tempfile.TemporaryDirectory() as tmpdir: |
| 522 | file_path = os.path.join(tmpdir, "some_file.ps") |
| 523 | with open(file_path, "w") as f: |
| 524 | f.write("some text") |
| 525 | |
| 526 | msg = ( |
| 527 | f"The file '{file_path}' already exists. To overwrite it use" |
| 528 | " the 'overwrite=True' argument of the save function." |
| 529 | ) |
| 530 | with self.assertRaisesRegex(FileExistsError, re.escape(msg)): |
| 531 | turtle.TurtleScreen.save(screen, file_path) |
| 532 | |
| 533 | def test_save_overwrites_if_specified(self) -> None: |
| 534 | screen = unittest.mock.Mock() |