From 95efc30ae7a73b59c84a5d3ecf9c8b95e05a66c7 Mon Sep 17 00:00:00 2001 From: Kapil Thangavelu Date: Sat, 15 Feb 2020 12:54:57 -0500 Subject: [PATCH] directory dependency - resolve relative paths --- poetry/packages/directory_dependency.py | 2 ++ tests/packages/test_directory_dependency.py | 24 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/poetry/packages/directory_dependency.py b/poetry/packages/directory_dependency.py index ac4bca8ea82..dd11bf8ea01 100644 --- a/poetry/packages/directory_dependency.py +++ b/poetry/packages/directory_dependency.py @@ -32,6 +32,8 @@ def __init__( if self._base and not self._path.is_absolute(): self._full_path = self._base / self._path + self._full_path = self._full_path.resolve() + if not self._full_path.exists(): raise ValueError("Directory {} does not exist".format(self._path)) diff --git a/tests/packages/test_directory_dependency.py b/tests/packages/test_directory_dependency.py index a557bb8c060..7b55997040f 100644 --- a/tests/packages/test_directory_dependency.py +++ b/tests/packages/test_directory_dependency.py @@ -1,3 +1,5 @@ +import os + from subprocess import CalledProcessError import pytest @@ -19,3 +21,25 @@ def run(self, bin, *args): def test_directory_dependency_must_exist(): with pytest.raises(ValueError): DirectoryDependency("demo", DIST_PATH / "invalid") + + +def test_directory_relative_path(): + assert ( + DirectoryDependency( + "demo", + Path( + os.path.sep.join( + [ + str(Path(__file__).parent), + "..", + "fixtures", + "git", + "github.com", + "demo", + "demo", + ] + ) + ), + ).full_path + == DIST_PATH / "demo" + )