Proper adding of 'directory/'

* added a test for adding single level directory with forward slash in the end
 * normalizing the path that is passed to the add method
This commit is contained in:
Emil Gotsev
2018-04-17 12:21:32 +03:00
parent 0c5cc47a86
commit 286153a609
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ class Project(object):
return os.path.relpath(path, self.root_dir)
def add(self, fname):
out = os.path.basename(fname)
out = os.path.basename(os.path.normpath(fname))
stage_fname = out + Stage.STAGE_FILE_SUFFIX
cwd = os.path.dirname(os.path.abspath(fname))
stage = Stage.loads(project=self,
+7
View File
@@ -49,6 +49,13 @@ class TestAddDirectory(TestDvc):
self.create(os.path.join(dname, 'file'), 'file')
self.dvc.add(dname)
class TestAddDirectoryWithForwardSlash(TestDvc):
def test(self):
dname = 'directory/'
os.mkdir(dname)
self.create(os.path.join(dname, 'file'), 'file')
stage = self.dvc.add(dname)
self.assertEquals(os.path.abspath('directory.dvc'), stage.path)
class TestAddTrackedFile(TestDvc):
def test(self):