Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
test_shutil_wrapper.py24 linesDownload Raw Back to tests
1import stat2import sys3from unittest.mock import Mock4 5from setuptools import _shutil6 7 8def test_rmtree_readonly(monkeypatch, tmp_path):9    """Verify onerr works as expected"""10 11    tmp_dir = tmp_path / "with_readonly"12    tmp_dir.mkdir()13    some_file = tmp_dir.joinpath("file.txt")14    some_file.touch()15    some_file.chmod(stat.S_IREAD)16 17    expected_count = 1 if sys.platform.startswith("win") else 018    chmod_fn = Mock(wraps=_shutil.attempt_chmod_verbose)19    monkeypatch.setattr(_shutil, "attempt_chmod_verbose", chmod_fn)20 21    _shutil.rmtree(tmp_dir)22    assert chmod_fn.call_count == expected_count23    assert not tmp_dir.is_dir()24 
codekingpro/portable-devtools · Team Ai