Exemplo n.º 1
0
def test_ensure_dir_creates_directory(
    tmp_path: Path, sync_filesystem: SyncFilesystem
) -> None:
    """It should ensure a directory exists."""
    path = tmp_path / "foo"

    sync_filesystem.ensure_dir(path)
    assert path.is_dir() is True

    # ensure that subsequent calls do not error
    sync_filesystem.ensure_dir(path)
    assert path.is_dir() is True
def test_ensure_dir_creates_dir(
    tmp_path: Path, sync_filesystem: SyncFilesystem
) -> None:
    """It should create a directory with ensure_dir if it doesn't exist."""
    dir_name = PurePosixPath(tmp_path) / "the_limit_does_not_exist"
    result = sync_filesystem.ensure_dir(dir_name)

    assert result == dir_name
    assert Path(dir_name).is_dir()
def test_ensure_dir_noops_when_dir_exists(
    tmp_path: Path, sync_filesystem: SyncFilesystem
) -> None:
    """It should do nothing with ensure_dir if the directory already exists."""
    tmp_path.mkdir(exist_ok=True)
    dir_name = PurePosixPath(tmp_path)
    result = sync_filesystem.ensure_dir(dir_name)

    assert dir_name == result