Skip to content

Commit

Permalink
directory dependency - resolve relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
kapilt committed Feb 15, 2020
1 parent ed44342 commit ebb97f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions poetry/packages/directory_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
23 changes: 23 additions & 0 deletions tests/packages/test_directory_dependency.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from subprocess import CalledProcessError

import pytest
Expand All @@ -19,3 +20,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"
)

0 comments on commit ebb97f0

Please sign in to comment.