mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 23:11:44 +01:00
appveyor: test py2 and py3
Related to #2166 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -24,7 +24,7 @@ from dvc.exceptions import DvcException, RecursiveAddingWhileUsingFilename
|
||||
from dvc.output.base import OutputAlreadyTrackedError
|
||||
from dvc.repo import Repo as DvcRepo
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.basic_env import TestDvc, TestDvcGit
|
||||
from tests.utils import spy, get_gitignore_content
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ class TestAddDirectoryWithForwardSlash(TestDvc):
|
||||
self.assertEqual(os.path.abspath("directory.dvc"), stage.path)
|
||||
|
||||
|
||||
class TestAddTrackedFile(TestDvc):
|
||||
class TestAddTrackedFile(TestDvcGit):
|
||||
def test(self):
|
||||
fname = "tracked_file"
|
||||
self.create(fname, "tracked file contents")
|
||||
@@ -266,7 +266,7 @@ class TestShouldUpdateStateEntryForFileAfterAdd(TestDvc):
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(file_md5_counter.mock.call_count, 1)
|
||||
|
||||
ret = main(["run", "-d", self.FOO, "cat {}".format(self.FOO)])
|
||||
ret = main(["run", "-d", self.FOO, "echo foo"])
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(file_md5_counter.mock.call_count, 1)
|
||||
|
||||
@@ -297,7 +297,7 @@ class TestShouldUpdateStateEntryForDirectoryAfterAdd(TestDvc):
|
||||
self.assertEqual(file_md5_counter.mock.call_count, 3)
|
||||
|
||||
ret = main(
|
||||
["run", "-d", self.DATA_DIR, "ls {}".format(self.DATA_DIR)]
|
||||
["run", "-d", self.DATA_DIR, "dir {}".format(self.DATA_DIR)]
|
||||
)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(file_md5_counter.mock.call_count, 3)
|
||||
@@ -468,7 +468,7 @@ class TestAddFilename(TestDvc):
|
||||
self.assertFalse(os.path.exists("foo.dvc"))
|
||||
|
||||
|
||||
class TestShouldCleanUpAfterFailedAdd(TestDvc):
|
||||
class TestShouldCleanUpAfterFailedAdd(TestDvcGit):
|
||||
def test(self):
|
||||
ret = main(["add", self.FOO])
|
||||
self.assertEqual(0, ret)
|
||||
|
||||
@@ -13,7 +13,8 @@ from dvc.repo import Repo as DvcRepo
|
||||
from dvc.system import System
|
||||
from dvc.utils import walk_files, relpath
|
||||
from dvc.utils.stage import load_stage_file, dump_stage_file
|
||||
from tests.basic_env import TestDvc
|
||||
from dvc.utils.compat import is_py2
|
||||
from tests.basic_env import TestDvc, TestDvcGit
|
||||
from tests.func.test_repro import TestRepro
|
||||
from dvc.stage import Stage, StageFileBadNameError, StageFileDoesNotExistError
|
||||
from dvc.remote.local import RemoteLOCAL
|
||||
@@ -113,7 +114,7 @@ class TestCmdCheckout(TestCheckout):
|
||||
self._test_checkout()
|
||||
|
||||
|
||||
class CheckoutBase(TestDvc):
|
||||
class CheckoutBase(TestDvcGit):
|
||||
GIT_IGNORE = ".gitignore"
|
||||
|
||||
def commit_data_file(self, fname, content="random text"):
|
||||
@@ -538,7 +539,7 @@ class TestCheckoutMovedCacheDirWithSymlinks(TestDvc):
|
||||
ret = main(["add", self.DATA_DIR])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
if os.name == "nt":
|
||||
if os.name == "nt" and is_py2:
|
||||
from jaraco.windows.filesystem import readlink
|
||||
else:
|
||||
readlink = os.readlink
|
||||
|
||||
@@ -183,7 +183,7 @@ def get_ssh_url_mocked(user, port):
|
||||
#
|
||||
# [1]https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-6
|
||||
drive, path = os.path.splitdrive(path)
|
||||
assert drive == "c:"
|
||||
assert drive.lower() == "c:"
|
||||
path = path.replace("\\", "/")
|
||||
url = "ssh://{}@127.0.0.1:{}{}".format(user, port, path)
|
||||
return url
|
||||
|
||||
@@ -10,7 +10,7 @@ import dvc.repo.diff as diff
|
||||
from dvc.command.diff import CmdDiff
|
||||
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.basic_env import TestDvcGit
|
||||
|
||||
|
||||
def _get_checksum(repo, file_name):
|
||||
@@ -20,7 +20,7 @@ def _get_checksum(repo, file_name):
|
||||
return out.checksum
|
||||
|
||||
|
||||
class TestDiff(TestDvc):
|
||||
class TestDiff(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestDiff, self).setUp()
|
||||
|
||||
@@ -88,7 +88,7 @@ class TestDiffCmdMessage(TestDiff):
|
||||
self.assertEqual(test_msg, msg)
|
||||
|
||||
|
||||
class TestDiffDir(TestDvc):
|
||||
class TestDiffDir(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestDiffDir, self).setUp()
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ from git import Repo
|
||||
from dvc.main import main
|
||||
from dvc.repo import Repo as DvcRepo
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.basic_env import TestDvcGit
|
||||
from tests.basic_env import TestDir
|
||||
|
||||
|
||||
class TestGC(TestDvc):
|
||||
class TestGC(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestGC, self).setUp()
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestGC(TestDvc):
|
||||
self.assertTrue(os.path.exists(c))
|
||||
|
||||
|
||||
class TestGCBranchesTags(TestDvc):
|
||||
class TestGCBranchesTags(TestDvcGit):
|
||||
def _check_cache(self, num):
|
||||
total = 0
|
||||
for root, dirs, files in os.walk(os.path.join(".dvc", "cache")):
|
||||
@@ -104,7 +104,7 @@ class TestGCBranchesTags(TestDvc):
|
||||
self._check_cache(1)
|
||||
|
||||
|
||||
class TestGCMultipleDvcRepos(TestDvc):
|
||||
class TestGCMultipleDvcRepos(TestDvcGit):
|
||||
def _check_cache(self, num):
|
||||
total = 0
|
||||
for root, dirs, files in os.walk(os.path.join(".dvc", "cache")):
|
||||
|
||||
@@ -15,7 +15,7 @@ class TestInstall(object):
|
||||
def _hook(self, name):
|
||||
return os.path.join(".git", "hooks", name)
|
||||
|
||||
def test_should_create_hooks(self, dvc_repo):
|
||||
def test_should_create_hooks(self, git, dvc_repo):
|
||||
assert main(["install"]) == 0
|
||||
|
||||
hooks_with_commands = [
|
||||
@@ -30,7 +30,7 @@ class TestInstall(object):
|
||||
with open(self._hook(fname), "r") as fobj:
|
||||
assert command in fobj.read()
|
||||
|
||||
def test_should_append_hooks_if_file_already_exists(self, dvc_repo):
|
||||
def test_should_append_hooks_if_file_already_exists(self, git, dvc_repo):
|
||||
with open(self._hook("post-checkout"), "w") as fobj:
|
||||
fobj.write("#!/bin/sh\n" "echo hello\n")
|
||||
|
||||
@@ -41,7 +41,7 @@ class TestInstall(object):
|
||||
with open(self._hook("post-checkout"), "r") as fobj:
|
||||
assert fobj.read() == expected_script
|
||||
|
||||
def test_should_be_idempotent(self, dvc_repo):
|
||||
def test_should_be_idempotent(self, git, dvc_repo):
|
||||
assert main(["install"]) == 0
|
||||
assert main(["install"]) == 0
|
||||
|
||||
@@ -50,7 +50,7 @@ class TestInstall(object):
|
||||
with open(self._hook("post-checkout"), "r") as fobj:
|
||||
assert fobj.read() == expected_script
|
||||
|
||||
def test_should_post_checkout_hook_checkout(self, repo_dir, dvc_repo):
|
||||
def test_should_post_checkout_hook_checkout(self, repo_dir, git, dvc_repo):
|
||||
assert main(["install"]) == 0
|
||||
|
||||
stage_file = repo_dir.FOO + Stage.STAGE_FILE_SUFFIX
|
||||
@@ -64,7 +64,7 @@ class TestInstall(object):
|
||||
|
||||
assert os.path.isfile(repo_dir.FOO)
|
||||
|
||||
def test_should_pre_push_hook_push(self, repo_dir, dvc_repo):
|
||||
def test_should_pre_push_hook_push(self, repo_dir, git, dvc_repo):
|
||||
assert main(["install"]) == 0
|
||||
|
||||
temp = repo_dir.mkdtemp()
|
||||
|
||||
@@ -11,10 +11,10 @@ from dvc.exceptions import DvcException, BadMetricError, NoMetricsError
|
||||
from dvc.repo.metrics.show import NO_METRICS_FILE_AT_REFERENCE_WARNING
|
||||
from dvc.stage import Stage
|
||||
from dvc.utils import relpath
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.basic_env import TestDvcGit
|
||||
|
||||
|
||||
class TestMetricsBase(TestDvc):
|
||||
class TestMetricsBase(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestMetricsBase, self).setUp()
|
||||
self.dvc.scm.commit("init")
|
||||
@@ -366,7 +366,7 @@ class TestMetrics(TestMetricsBase):
|
||||
)
|
||||
|
||||
|
||||
class TestMetricsRecursive(TestDvc):
|
||||
class TestMetricsRecursive(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestMetricsRecursive, self).setUp()
|
||||
self.dvc.scm.commit("init")
|
||||
@@ -430,7 +430,7 @@ class TestMetricsRecursive(TestDvc):
|
||||
)
|
||||
|
||||
|
||||
class TestMetricsReproCLI(TestDvc):
|
||||
class TestMetricsReproCLI(TestDvcGit):
|
||||
def test(self):
|
||||
stage = self.dvc.run(
|
||||
metrics_no_cache=["metrics"],
|
||||
@@ -627,7 +627,7 @@ class TestMetricsCLI(TestMetricsBase):
|
||||
assert "\tmetric.unknown: unknown" in self._caplog.text
|
||||
|
||||
|
||||
class TestNoMetrics(TestDvc):
|
||||
class TestNoMetrics(TestDvcGit):
|
||||
def test(self):
|
||||
with self.assertRaises(NoMetricsError):
|
||||
self.dvc.metrics.show()
|
||||
@@ -637,7 +637,7 @@ class TestNoMetrics(TestDvc):
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
|
||||
class TestCachedMetrics(TestDvc):
|
||||
class TestCachedMetrics(TestDvcGit):
|
||||
def _do_add(self, branch):
|
||||
self.dvc.scm.checkout(branch)
|
||||
self.dvc.checkout(force=True)
|
||||
@@ -731,7 +731,7 @@ class TestCachedMetrics(TestDvc):
|
||||
self._test_metrics(self._do_run)
|
||||
|
||||
|
||||
class TestMetricsType(TestDvc):
|
||||
class TestMetricsType(TestDvcGit):
|
||||
branches = ["foo", "bar", "baz"]
|
||||
files = [
|
||||
"metric",
|
||||
@@ -810,7 +810,7 @@ class TestShouldDisplayMetricsEvenIfMetricIsMissing(object):
|
||||
|
||||
self._commit_metric(dvc, "master")
|
||||
|
||||
def test(self, dvc_repo, caplog):
|
||||
def test(self, git, dvc_repo, caplog):
|
||||
self.setUp(dvc_repo)
|
||||
|
||||
dvc_repo.scm.checkout(self.BRANCH_MISSING_METRIC)
|
||||
|
||||
@@ -5,7 +5,7 @@ from dvc.exceptions import DvcException, MoveNotDataSourceError
|
||||
from dvc.stage import Stage
|
||||
from dvc.utils.stage import load_stage_file
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.basic_env import TestDvc, TestDvcGit
|
||||
from tests.func.test_repro import TestRepro
|
||||
from tests.utils import cd
|
||||
|
||||
@@ -122,19 +122,17 @@ class TestMoveFileToDirectoryWithoutSpecifiedTargetName(TestDvc):
|
||||
self.assertEqual(self.FOO, new_stage["outs"][0]["path"])
|
||||
|
||||
|
||||
class TestMoveDirectoryShouldNotOverwriteExisting(TestDvc):
|
||||
class TestMoveDirectoryShouldNotOverwriteExisting(TestDvcGit):
|
||||
def test(self):
|
||||
dir_name = "dir"
|
||||
orig_listdir = set(os.listdir(self.DATA_DIR))
|
||||
|
||||
ret = main(["add", self.DATA_DIR])
|
||||
self.assertEqual(ret, 0)
|
||||
self.dvc.add(self.DATA_DIR)
|
||||
|
||||
os.mkdir(dir_name)
|
||||
new_dir_name = os.path.join(dir_name, self.DATA_DIR)
|
||||
|
||||
ret = main(["move", self.DATA_DIR, dir_name])
|
||||
self.assertEqual(ret, 0)
|
||||
self.dvc.move(self.DATA_DIR, dir_name)
|
||||
|
||||
data_dir_stage = self.DATA_DIR + Stage.STAGE_FILE_SUFFIX
|
||||
self.assertFalse(os.path.exists(self.DATA_DIR))
|
||||
|
||||
+40
-49
@@ -25,10 +25,6 @@ class TestPipelineShowSingle(TestDvc):
|
||||
ret = main(["pipeline", "show", self.stage, "--outs"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_ascii(self):
|
||||
ret = main(["pipeline", "show", "--ascii", self.stage])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_dot(self):
|
||||
ret = main(["pipeline", "show", "--dot", self.stage])
|
||||
self.assertEqual(ret, 0)
|
||||
@@ -37,10 +33,6 @@ class TestPipelineShowSingle(TestDvc):
|
||||
ret = main(["pipeline", "show", "--tree", self.stage])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_ascii_commands(self):
|
||||
ret = main(["pipeline", "show", "--ascii", self.stage, "--commands"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_ascii_outs(self):
|
||||
ret = main(["pipeline", "show", "--ascii", self.stage, "--outs"])
|
||||
self.assertEqual(ret, 0)
|
||||
@@ -62,10 +54,17 @@ class TestPipelineShowSingle(TestDvc):
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
|
||||
class TestPipelineShow(TestRepro):
|
||||
def setUp(self):
|
||||
super(TestPipelineShow, self).setUp()
|
||||
def test_single_ascii(repo_dir, dvc_repo):
|
||||
dvc_repo.add(repo_dir.FOO)
|
||||
assert main(["pipeline", "show", "--ascii", "foo.dvc"]) == 0
|
||||
|
||||
|
||||
def test_single_ascii_commands(repo_dir, dvc_repo):
|
||||
dvc_repo.add(repo_dir.FOO)
|
||||
assert main(["pipeline", "show", "--ascii", "foo.dvc", "--commands"]) == 0
|
||||
|
||||
|
||||
class TestPipelineShow(TestRepro):
|
||||
def test(self):
|
||||
ret = main(["pipeline", "show", self.file1_stage])
|
||||
self.assertEqual(ret, 0)
|
||||
@@ -74,10 +73,6 @@ class TestPipelineShow(TestRepro):
|
||||
ret = main(["pipeline", "show", self.file1_stage, "--commands"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_outs(self):
|
||||
ret = main(["pipeline", "show", self.file1_stage, "--outs"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_ascii(self):
|
||||
ret = main(["pipeline", "show", "--ascii", self.file1_stage])
|
||||
self.assertEqual(ret, 0)
|
||||
@@ -102,36 +97,40 @@ class TestPipelineShow(TestRepro):
|
||||
)
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_dot_outs(self):
|
||||
ret = main(["pipeline", "show", "--dot", self.file1_stage, "--outs"])
|
||||
|
||||
def test_print_locked_stages(repo_dir, dvc_repo, caplog):
|
||||
dvc_repo.add("foo")
|
||||
dvc_repo.add("bar")
|
||||
dvc_repo.lock_stage("foo.dvc")
|
||||
|
||||
caplog.clear()
|
||||
with caplog.at_level(logging.INFO, logger="dvc"):
|
||||
assert main(["pipeline", "show", "foo.dvc", "--locked"]) == 0
|
||||
|
||||
assert "foo.dvc" in caplog.text
|
||||
assert "bar.dvc" not in caplog.text
|
||||
|
||||
|
||||
def test_dot_outs(repo_dir, dvc_repo):
|
||||
dvc_repo.add(repo_dir.FOO)
|
||||
dvc_repo.run(
|
||||
outs=["file"],
|
||||
deps=[repo_dir.FOO, repo_dir.CODE],
|
||||
cmd="python {} {} {}".format(repo_dir.CODE, repo_dir.FOO, "file"),
|
||||
)
|
||||
assert main(["pipeline", "show", "--dot", "file.dvc", "--outs"]) == 0
|
||||
|
||||
|
||||
class TestPipelineShowOuts(TestRepro):
|
||||
def setUp(self):
|
||||
super(TestPipelineShowOuts, self).setUp()
|
||||
|
||||
def test_outs(self):
|
||||
ret = main(["pipeline", "show", self.file1_stage, "--outs"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_not_dvc_file(self):
|
||||
ret = main(["pipeline", "show", self.file1])
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
def test_non_existing(self):
|
||||
ret = main(["pipeline", "show", "non-existing"])
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
def test_print_locked_stages(self):
|
||||
self.dvc.add("foo")
|
||||
self.dvc.add("bar")
|
||||
self.dvc.lock_stage("foo.dvc")
|
||||
|
||||
self._caplog.clear()
|
||||
with self._caplog.at_level(logging.INFO, logger="dvc"):
|
||||
ret = main(["pipeline", "show", "foo.dvc", "--locked"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
assert "foo.dvc" in self._caplog.text
|
||||
assert "bar.dvc" not in self._caplog.text
|
||||
|
||||
|
||||
class TestPipelineShowDeep(TestReproChangedDeepData):
|
||||
def setUp(self):
|
||||
super(TestPipelineShowDeep, self).setUp()
|
||||
|
||||
def test(self):
|
||||
ret = main(["pipeline", "show", self.file1_stage])
|
||||
self.assertEqual(ret, 0)
|
||||
@@ -172,14 +171,6 @@ class TestPipelineShowDeep(TestReproChangedDeepData):
|
||||
ret = main(["pipeline", "show", "--dot", self.file1_stage, "--outs"])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_not_dvc_file(self):
|
||||
ret = main(["pipeline", "show", self.file1])
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
def test_non_existing(self):
|
||||
ret = main(["pipeline", "show", "non-existing"])
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
|
||||
class TestPipelineListEmpty(TestDvc):
|
||||
def test(self):
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from dvc.main import main
|
||||
from dvc.stage import Stage
|
||||
from tests.basic_env import TestDvc
|
||||
from tests.basic_env import TestDvcGit
|
||||
|
||||
from dvc.scm.git import GitTree
|
||||
from dvc.scm.tree import WorkingTree
|
||||
|
||||
|
||||
class TestCollect(TestDvc):
|
||||
class TestCollect(TestDvcGit):
|
||||
def setUp(self):
|
||||
super(TestCollect, self).setUp()
|
||||
self.dvc.add(self.FOO)
|
||||
@@ -46,7 +46,7 @@ class TestCollect(TestDvc):
|
||||
self.assertEqual([str(i) for i in result[0].deps], ["bar"])
|
||||
|
||||
|
||||
class TestIgnore(TestDvc):
|
||||
class TestIgnore(TestDvcGit):
|
||||
def _stage_name(self, file):
|
||||
return file + Stage.STAGE_FILE_SUFFIX
|
||||
|
||||
|
||||
@@ -1242,13 +1242,6 @@ class TestReproShell(TestDvc):
|
||||
self.assertEqual(os.getenv("SHELL"), fd.read().strip())
|
||||
|
||||
|
||||
class TestReproNoSCM(TestRepro):
|
||||
def test(self):
|
||||
shutil.rmtree(self.dvc.scm.dir)
|
||||
ret = main(["repro", self.file1_stage])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
|
||||
class TestReproAllPipelines(TestDvc):
|
||||
def test(self):
|
||||
self.dvc.run(
|
||||
|
||||
+35
-60
@@ -7,6 +7,8 @@ import shutil
|
||||
import filecmp
|
||||
import subprocess
|
||||
import signal
|
||||
import threading
|
||||
import pytest
|
||||
|
||||
from dvc.main import main
|
||||
from dvc.output import OutputBase
|
||||
@@ -280,91 +282,64 @@ class TestRunBadName(TestDvc):
|
||||
)
|
||||
|
||||
|
||||
class TestCmdRun(TestDvc):
|
||||
def test_run(self):
|
||||
ret = main(
|
||||
@pytest.mark.skipif(
|
||||
not isinstance(threading.current_thread(), threading._MainThread),
|
||||
reason="Not running in the main thread.",
|
||||
)
|
||||
@mock.patch.object(subprocess.Popen, "wait", new=KeyboardInterrupt)
|
||||
def test_keyboard_interrupt(repo_dir, dvc_repo):
|
||||
assert (
|
||||
main(
|
||||
[
|
||||
"run",
|
||||
"-d",
|
||||
self.FOO,
|
||||
repo_dir.FOO,
|
||||
"-d",
|
||||
self.CODE,
|
||||
repo_dir.CODE,
|
||||
"-o",
|
||||
"out",
|
||||
"-f",
|
||||
"out.dvc",
|
||||
"python",
|
||||
self.CODE,
|
||||
self.FOO,
|
||||
repo_dir.CODE,
|
||||
repo_dir.FOO,
|
||||
"out",
|
||||
]
|
||||
)
|
||||
== 1
|
||||
)
|
||||
|
||||
stage = Stage.load(self.dvc, fname="out.dvc")
|
||||
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertTrue(os.path.isfile("out"))
|
||||
self.assertTrue(os.path.isfile("out.dvc"))
|
||||
self.assertTrue(filecmp.cmp(self.FOO, "out", shallow=False))
|
||||
self.assertEqual(stage.cmd, "python code.py foo out")
|
||||
|
||||
def test_run_args_from_cli(self):
|
||||
ret = main(["run", "echo", "foo"])
|
||||
stage = Stage.load(self.dvc, fname="Dvcfile")
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(stage.cmd, "echo foo")
|
||||
|
||||
def test_run_bad_command(self):
|
||||
ret = main(["run", "non-existing-command"])
|
||||
self.assertNotEqual(ret, 0)
|
||||
|
||||
def test_run_args_with_spaces(self):
|
||||
ret = main(["run", "echo", "foo bar"])
|
||||
stage = Stage.load(self.dvc, fname="Dvcfile")
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(stage.cmd, 'echo "foo bar"')
|
||||
|
||||
@mock.patch.object(subprocess.Popen, "wait", new=KeyboardInterrupt)
|
||||
def test_keyboard_interrupt(self):
|
||||
ret = main(
|
||||
@pytest.mark.skipif(
|
||||
not isinstance(threading.current_thread(), threading._MainThread),
|
||||
reason="Not running in the main thread.",
|
||||
)
|
||||
def test_keyboard_interrupt_after_second_signal_call(
|
||||
mocker, repo_dir, dvc_repo
|
||||
):
|
||||
mocker.patch.object(
|
||||
signal, "signal", side_effect=[None, KeyboardInterrupt]
|
||||
)
|
||||
assert (
|
||||
main(
|
||||
[
|
||||
"run",
|
||||
"-d",
|
||||
self.FOO,
|
||||
repo_dir.FOO,
|
||||
"-d",
|
||||
self.CODE,
|
||||
repo_dir.CODE,
|
||||
"-o",
|
||||
"out",
|
||||
"-f",
|
||||
"out.dvc",
|
||||
"python",
|
||||
self.CODE,
|
||||
self.FOO,
|
||||
repo_dir.CODE,
|
||||
repo_dir.FOO,
|
||||
"out",
|
||||
]
|
||||
)
|
||||
self.assertEqual(ret, 1)
|
||||
|
||||
@mock.patch.object(signal, "signal", side_effect=[None, KeyboardInterrupt])
|
||||
def test_keyboard_interrupt_after_second_signal_call(self, _):
|
||||
ret = main(
|
||||
[
|
||||
"run",
|
||||
"-d",
|
||||
self.FOO,
|
||||
"-d",
|
||||
self.CODE,
|
||||
"-o",
|
||||
"out",
|
||||
"-f",
|
||||
"out.dvc",
|
||||
"python",
|
||||
self.CODE,
|
||||
self.FOO,
|
||||
"out",
|
||||
]
|
||||
)
|
||||
self.assertEqual(ret, 252)
|
||||
== 252
|
||||
)
|
||||
|
||||
|
||||
class TestRunRemoveOuts(TestDvc):
|
||||
@@ -977,7 +952,7 @@ class TestShouldNotCheckoutUponCorruptedLocalHardlinkCache(TestDvc):
|
||||
self.dvc = DvcRepo(".")
|
||||
|
||||
def test(self):
|
||||
cmd = "cp {} {}".format(self.FOO, self.BAR)
|
||||
cmd = "python {} {} {}".format(self.CODE, self.FOO, self.BAR)
|
||||
stage = self.dvc.run(deps=[self.FOO], outs=[self.BAR], cmd=cmd)
|
||||
|
||||
with open(self.BAR, "w") as fd:
|
||||
|
||||
Reference in New Issue
Block a user