Skip to content

Commit

Permalink
package: allow url dependencies to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tommilligan authored and abn committed Apr 5, 2020
1 parent 64c054b commit 4888d21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ def add_dependency(
develop=constraint.get("develop", True),
)
elif "url" in constraint:
dependency = URLDependency(name, constraint["url"], category=category)
dependency = URLDependency(
name, constraint["url"], category=category, optional=optional
)
else:
version = constraint["version"]

Expand Down
17 changes: 17 additions & 0 deletions tests/packages/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,20 @@ def test_package_add_dependency_vcs_category_default_main():
"poetry", constraint={"git": "https://github.com/python-poetry/poetry.git"}
)
assert dependency.category == "main"


@pytest.mark.parametrize("category", ["main", "dev"])
@pytest.mark.parametrize("optional", [True, False])
def test_package_url_category_optional(category, optional):
package = Package("foo", "0.1.0")

dependency = package.add_dependency(
"poetry",
constraint={
"url": "https://github.com/python-poetry/poetry/releases/download/1.0.5/poetry-1.0.5-linux.tar.gz",
"optional": optional,
},
category=category,
)
assert dependency.category == category
assert dependency.is_optional() == optional

0 comments on commit 4888d21

Please sign in to comment.