mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 23:10:42 +01:00
fix metrics tests on windows
This commit is contained in:
+18
-2
@@ -378,10 +378,26 @@ class TestCachedMetrics(TestDvc):
|
||||
self.dvc.scm.checkout(branch)
|
||||
self.dvc.checkout(force=True)
|
||||
|
||||
content = json.dumps({"metrics": branch})
|
||||
print(
|
||||
'print(json.dumps({{"metrics": "{branch}"}})\n'.format(
|
||||
branch=branch
|
||||
)
|
||||
)
|
||||
|
||||
with open("code.py", "w+") as fobj:
|
||||
fobj.write("import sys\n")
|
||||
fobj.write("import os\n")
|
||||
fobj.write("import json\n")
|
||||
fobj.write(
|
||||
'print(json.dumps({{"metrics": "{branch}"}}))\n'.format(
|
||||
branch=branch
|
||||
)
|
||||
)
|
||||
|
||||
stage = self.dvc.run(
|
||||
deps=["code.py"],
|
||||
metrics=["metrics.json"],
|
||||
cmd="echo '{content}' > metrics.json".format(content=content),
|
||||
cmd="python code.py metrics.json > metrics.json",
|
||||
)
|
||||
self.assertIsNotNone(stage)
|
||||
self.assertEqual(stage.relpath, "metrics.json.dvc")
|
||||
|
||||
+4
-8
@@ -532,18 +532,14 @@ class TestCmdRunOverwrite(TestDvc):
|
||||
|
||||
class TestCmdRunCliMetrics(TestDvc):
|
||||
def test_cached(self):
|
||||
ret = main(
|
||||
["run", "-m", "metrics.txt", "echo -n 'test' > metrics.txt"]
|
||||
)
|
||||
ret = main(["run", "-m", "metrics.txt", "echo 'test' > metrics.txt"])
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(open("metrics.txt", "r").read(), "test")
|
||||
self.assertEqual(open("metrics.txt", "r").read().rstrip(), "test")
|
||||
|
||||
def test_not_cached(self):
|
||||
ret = main(
|
||||
["run", "-M", "metrics.txt", "echo -n 'test' > metrics.txt"]
|
||||
)
|
||||
ret = main(["run", "-M", "metrics.txt", "echo 'test' > metrics.txt"])
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(open("metrics.txt", "r").read(), "test")
|
||||
self.assertEqual(open("metrics.txt", "r").read().rstrip(), "test")
|
||||
|
||||
|
||||
class TestRunDeterministicBase(TestDvc):
|
||||
|
||||
Reference in New Issue
Block a user