Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ def create_dependency(
file_path,
directory=constraint.get("subdirectory", None),
groups=groups,
optional=optional,
base=root_dir,
extras=constraint.get("extras", []),
)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,24 @@ def test_create_dependency_allow_prereleases(
assert dep.allows_prereleases() is expected


@pytest.mark.parametrize("dependency_type", ["file", "path"])
@pytest.mark.parametrize("optional", [None, False, True])
def test_create_dependency_optional_file(
dependency_type: str, optional: bool | None
) -> None:
constraint: dict[str, Any] = {
dependency_type: "distributions/demo-0.1.0-py2.py3-none-any.whl"
}
if optional is not None:
constraint["optional"] = optional

dependency = Factory.create_dependency("demo", constraint, root_dir=fixtures_dir)

assert dependency.is_file()
assert dependency.is_optional() is (optional is True)
assert dependency.is_activated() is (optional is not True)


def test_all_classifiers_unique_even_if_classifiers_is_duplicated() -> None:
poetry = Factory().create_poetry(
fixtures_dir / "project_with_duplicated_classifiers"
Expand Down
Loading