def test_rmtree(self, tmp_path): from _pytest.pathlib import rmtree adir = tmp_path / "adir" adir.mkdir() rmtree(adir) assert not adir.exists() adir.mkdir() afile = adir / "afile" afile.write_bytes(b"aa") rmtree(adir, force=True) assert not adir.exists()