(self, tmp_path: Path)
| 358 | assert not adir.is_dir() |
| 359 | |
| 360 | def test_on_rm_rf_error(self, tmp_path: Path) -> None: |
| 361 | adir = tmp_path / "dir" |
| 362 | adir.mkdir() |
| 363 | |
| 364 | fn = adir / "foo.txt" |
| 365 | fn.touch() |
| 366 | self.chmod_r(fn) |
| 367 | |
| 368 | # unknown exception |
| 369 | with pytest.warns(pytest.PytestWarning): |
| 370 | exc_info1 = (None, RuntimeError(), None) |
| 371 | on_rm_rf_error(os.unlink, str(fn), exc_info1, start_path=tmp_path) |
| 372 | assert fn.is_file() |
| 373 | |
| 374 | # we ignore FileNotFoundError |
| 375 | exc_info2 = (None, FileNotFoundError(), None) |
| 376 | assert not on_rm_rf_error(None, str(fn), exc_info2, start_path=tmp_path) |
| 377 | |
| 378 | # unknown function |
| 379 | with pytest.warns( |
| 380 | pytest.PytestWarning, |
| 381 | match=r"^\(rm_rf\) unknown function None when removing .*foo.txt:\nNone: ", |
| 382 | ): |
| 383 | exc_info3 = (None, PermissionError(), None) |
| 384 | on_rm_rf_error(None, str(fn), exc_info3, start_path=tmp_path) |
| 385 | assert fn.is_file() |
| 386 | |
| 387 | # ignored function |
| 388 | with warnings.catch_warnings(): |
| 389 | warnings.simplefilter("ignore") |
| 390 | with pytest.warns(None) as warninfo: # type: ignore[call-overload] |
| 391 | exc_info4 = (None, PermissionError(), None) |
| 392 | on_rm_rf_error(os.open, str(fn), exc_info4, start_path=tmp_path) |
| 393 | assert fn.is_file() |
| 394 | assert not [x.message for x in warninfo] |
| 395 | |
| 396 | exc_info5 = (None, PermissionError(), None) |
| 397 | on_rm_rf_error(os.unlink, str(fn), exc_info5, start_path=tmp_path) |
| 398 | assert not fn.is_file() |
| 399 | |
| 400 | |
| 401 | def attempt_symlink_to(path, to_path): |
nothing calls this directly
no test coverage detected