1- from mock import patch
1+ import os
22
3+ from mock import patch
34from dvc .output import OutputLOCAL
45from dvc .remote .local import RemoteLOCAL
56from dvc .stage import Stage
7+ from dvc .utils import relpath
68from tests .basic_env import TestDvc
79
810
@@ -21,6 +23,34 @@ def test_save_missing(self):
2123 o .save ()
2224
2325
26+ def test_str_workdir_outside_repo (erepo ):
27+ stage = Stage (erepo .dvc )
28+ output = OutputLOCAL (stage , "path" , cache = False )
29+
30+ assert relpath ("path" , erepo .dvc .root_dir ) == str (output )
31+
32+
33+ def test_str_workdir_inside_repo (dvc_repo ):
34+ stage = Stage (dvc_repo )
35+ output = OutputLOCAL (stage , "path" , cache = False )
36+
37+ assert "path" == str (output )
38+
39+ stage = Stage (dvc_repo , wdir = "some_folder" )
40+ output = OutputLOCAL (stage , "path" , cache = False )
41+
42+ assert os .path .join ("some_folder" , "path" ) == str (output )
43+
44+
45+ def test_str_on_absolute_path (dvc_repo ):
46+ stage = Stage (dvc_repo )
47+
48+ path = os .path .abspath (os .path .join ("path" , "to" , "file" ))
49+ output = OutputLOCAL (stage , path , cache = False )
50+
51+ assert path == str (output )
52+
53+
2454class TestGetFilesNumber (TestDvc ):
2555 def _get_output (self ):
2656 stage = Stage (self .dvc )
0 commit comments