Пример #1
0
def test_exists(filesystem: FileSystemImpl,
                lpaths: Dict[str, AbstractPath]) -> None:
    assert filesystem._exists(lpaths['root'])
    assert filesystem._exists(lpaths['dir'])
    assert filesystem._exists(lpaths['file'])
    assert filesystem._exists(lpaths['link'])
    assert not filesystem._exists(lpaths['broken_link'])
    assert not filesystem._exists(lpaths['link_loop'])
Пример #2
0
def test_rename(filesystem: FileSystemImpl,
                lpaths: Dict[str, AbstractPath]) -> None:
    assert not filesystem._exists(lpaths['new_file'])
    assert filesystem._exists(lpaths['file'])
    filesystem._rename(lpaths['file'], lpaths['new_file'])
    assert filesystem._exists(lpaths['new_file'])
    assert not filesystem._exists(lpaths['file'])
    filesystem._rename(lpaths['new_file'], lpaths['file'])
Пример #3
0
def test_symlink_to(filesystem: FileSystemImpl,
                    lpaths: Dict[str, AbstractPath]) -> None:
    if filesystem._supports('symlinks'):
        filesystem._symlink_to(lpaths['new_file'], lpaths['file'])
        assert filesystem._is_symlink(lpaths['new_file'])
        assert filesystem._is_file(lpaths['new_file'])
        filesystem._unlink(lpaths['new_file'])
        assert not filesystem._exists(lpaths['new_file'])
        assert filesystem._exists(lpaths['file'])
Пример #4
0
def test_touch(filesystem: FileSystemImpl, lpaths: Dict[str,
                                                        AbstractPath]) -> None:
    path = lpaths['new_file']
    filesystem._touch(path)
    assert filesystem._exists(path)
    # clean up, since we're reusing the file system
    filesystem._unlink(path)
Пример #5
0
def test_rmdir(filesystem: FileSystemImpl, lpaths: Dict[str,
                                                        AbstractPath]) -> None:
    filesystem._mkdir(lpaths['new_dir'])
    filesystem._rmdir(lpaths['new_dir'])
    assert not filesystem._exists(lpaths['new_dir'])

    with pytest.raises(OSError):
        filesystem._rmdir(lpaths['root'])

    filesystem._mkdir(lpaths['new_dir'])
    filesystem._touch(lpaths['new_dir'] / 'file.txt')
    filesystem._rmdir(lpaths['new_dir'], recursive=True)
    assert not filesystem._exists(lpaths['new_dir'])

    with pytest.raises(RuntimeError):
        filesystem._rmdir(lpaths['file'])
Пример #6
0
def test_unlink(filesystem: FileSystemImpl,
                lpaths: Dict[str, AbstractPath]) -> None:
    filesystem._touch(lpaths['new_file'])
    assert filesystem._exists(lpaths['new_file'])
    filesystem._unlink(lpaths['new_file'])
    assert not filesystem._exists(lpaths['new_file'])