mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
* get/import/url: handle existing output directory Currently if you run ``` dvc get https://github.com/iterative/example-get-started model.pkl --out . ``` it will nuke your cwd. To fix that we need to properly handle existing directories, same as usual unix cli utilities do that. * travis: specify python version when installing from chocolatey Fixes #2609
35 lines
719 B
Python
35 lines
719 B
Python
from __future__ import unicode_literals
|
|
|
|
import os
|
|
import filecmp
|
|
|
|
import pytest
|
|
|
|
from dvc.repo import Repo
|
|
from dvc.utils import makedirs
|
|
|
|
|
|
def test_get_file(repo_dir):
|
|
src = repo_dir.FOO
|
|
dst = repo_dir.FOO + "_imported"
|
|
|
|
Repo.get_url(src, dst)
|
|
|
|
assert os.path.exists(dst)
|
|
assert os.path.isfile(dst)
|
|
assert filecmp.cmp(repo_dir.FOO, dst, shallow=False)
|
|
|
|
|
|
@pytest.mark.parametrize("dname", [".", "dir", "dir/subdir"])
|
|
def test_get_url_to_dir(dname, repo_dir):
|
|
src = repo_dir.DATA
|
|
|
|
makedirs(dname, exist_ok=True)
|
|
|
|
Repo.get_url(src, dname)
|
|
|
|
dst = os.path.join(dname, os.path.basename(src))
|
|
|
|
assert os.path.isdir(dname)
|
|
assert filecmp.cmp(repo_dir.DATA, dst, shallow=False)
|