Example #1
0
    def test_rm_rf_with_read_only_directory(self, tmp_path):
        """Ensure rm_rf can remove read-only directories (#5524)"""
        adir = tmp_path / "dir"
        adir.mkdir()

        (adir / "foo.txt").touch()
        self.chmod_r(adir)

        rm_rf(adir)

        assert not adir.is_dir()
Example #2
0
    def test_rm_rf_with_read_only_file(self, tmp_path):
        """Ensure rm_rf can remove directories with read-only files in them (#5524)"""
        fn = tmp_path / "dir/foo.txt"
        fn.parent.mkdir()

        fn.touch()

        self.chmod_r(fn)

        rm_rf(fn.parent)

        assert not fn.parent.is_dir()
Example #3
0
    def test_rm_rf(self, tmp_path):
        adir = tmp_path / "adir"
        adir.mkdir()
        rm_rf(adir)

        assert not adir.exists()

        adir.mkdir()
        afile = adir / "afile"
        afile.write_bytes(b"aa")

        rm_rf(adir)
        assert not adir.exists()
Example #4
0
    def test_rmtree_with_read_only_directory(self, tmp_path):
        """Ensure rm_rf can remove read-only directories (#5524)"""
        from _pytest.pathlib import rm_rf

        adir = tmp_path / "dir"
        adir.mkdir()

        (adir / "foo.txt").touch()
        mode = os.stat(str(adir)).st_mode
        os.chmod(str(adir), mode & ~stat.S_IWRITE)

        rm_rf(adir)

        assert not adir.is_dir()
Example #5
0
    def test_rm_rf(self, tmp_path):
        from _pytest.pathlib import rm_rf

        adir = tmp_path / "adir"
        adir.mkdir()
        rm_rf(adir)

        assert not adir.exists()

        adir.mkdir()
        afile = adir / "afile"
        afile.write_bytes(b"aa")

        rm_rf(adir)
        assert not adir.exists()
Example #6
0
    def test_rmtree_with_read_only_file(self, tmp_path):
        """Ensure rm_rf can remove directories with read-only files in them (#5524)"""
        from _pytest.pathlib import rm_rf

        fn = tmp_path / "dir/foo.txt"
        fn.parent.mkdir()

        fn.touch()

        mode = os.stat(str(fn)).st_mode
        os.chmod(str(fn), mode & ~stat.S_IWRITE)

        rm_rf(fn.parent)

        assert not fn.parent.is_dir()