(self, tmp_path: Path)
| 567 | assert not adir.is_dir() |
| 568 | |
| 569 | def test_on_rm_rf_error(self, tmp_path: Path) -> None: |
| 570 | adir = tmp_path / "dir" |
| 571 | adir.mkdir() |
| 572 | |
| 573 | fn = adir / "foo.txt" |
| 574 | fn.touch() |
| 575 | self.chmod_r(fn) |
| 576 | |
| 577 | # unknown exception |
| 578 | with pytest.warns(pytest.PytestWarning): |
| 579 | exc_info1 = (RuntimeError, RuntimeError(), None) |
| 580 | on_rm_rf_error(os.unlink, str(fn), exc_info1, start_path=tmp_path) |
| 581 | assert fn.is_file() |
| 582 | |
| 583 | # we ignore FileNotFoundError |
| 584 | exc_info2 = (FileNotFoundError, FileNotFoundError(), None) |
| 585 | assert not on_rm_rf_error(None, str(fn), exc_info2, start_path=tmp_path) |
| 586 | |
| 587 | # unknown function |
| 588 | with pytest.warns( |
| 589 | pytest.PytestWarning, |
| 590 | match=r"^\(rm_rf\) unknown function None when removing .*foo.txt:\n<class 'PermissionError'>: ", |
| 591 | ): |
| 592 | exc_info3 = (PermissionError, PermissionError(), None) |
| 593 | on_rm_rf_error(None, str(fn), exc_info3, start_path=tmp_path) |
| 594 | assert fn.is_file() |
| 595 | |
| 596 | # ignored function |
| 597 | with warnings.catch_warnings(record=True) as w: |
| 598 | exc_info4 = PermissionError() |
| 599 | on_rm_rf_error(os.open, str(fn), exc_info4, start_path=tmp_path) |
| 600 | assert fn.is_file() |
| 601 | assert not [x.message for x in w] |
| 602 | |
| 603 | exc_info5 = PermissionError() |
| 604 | on_rm_rf_error(os.unlink, str(fn), exc_info5, start_path=tmp_path) |
| 605 | assert not fn.is_file() |
| 606 | |
| 607 | |
| 608 | def attempt_symlink_to(path, to_path): |
nothing calls this directly
no test coverage detected