def test_make_writable(): from conda.gateways.disk.permissions import make_writable with tempdir() as td: test_path = join(td, 'test_path') touch(test_path) assert isfile(test_path) _try_open(test_path) _make_read_only(test_path) pytest.raises((IOError, OSError), _try_open, test_path) make_writable(test_path) _try_open(test_path) assert _can_write_file(test_path, "welcome to the ministry of silly walks") os.remove(test_path) assert not isfile(test_path)
def test_make_writable_dir_EROFS(): import conda.gateways.disk.permissions from conda.gateways.disk.permissions import make_writable with patch.object(conda.gateways.disk.permissions, 'chmod') as chmod_mock: chmod_mock.side_effect = IOError(EROFS, 'some message', 'foo') with tempdir() as td: assert not make_writable(td)
def test_make_writable_dir_EPERM(): import conda.gateways.disk.permissions from conda.gateways.disk.permissions import make_writable with patch.object(conda.gateways.disk.permissions, 'chmod') as chmod_mock: chmod_mock.side_effect = IOError(EACCES, 'some message', 'foo') with tempdir() as td: assert not make_writable(td)
def test_make_writable_doesnt_exist(): from conda.gateways.disk.permissions import make_writable with pytest.raises((IOError, OSError)) as exc: make_writable(join('some', 'path', 'that', 'definitely', 'doesnt', 'exist')) assert exc.value.errno == ENOENT
def test_make_writable_doesnt_exist(): from conda.gateways.disk.permissions import make_writable with pytest.raises((IOError, OSError)) as exc: make_writable( join('some', 'path', 'that', 'definitely', 'doesnt', 'exist')) assert exc.value.errno == ENOENT