Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure optional dev-dependencies are written to extras. #606

Closed
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
2 changes: 1 addition & 1 deletion poetry/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def create(cls, cwd): # type: (Path) -> Poetry
for req in requirements:
req = Dependency(req, "*")

for dep in package.requires:
for dep in package.all_requires:
if dep.name == req.name:
dep.in_extras.append(extra_name)
package.extras[extra_name].append(dep)
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/project_with_extras/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ cachy = { version = ">=0.2.0", optional = true }
[tool.poetry.extras]
extras_a = [ "pendulum" ]
extras_b = [ "cachy" ]
extras_c = [ "black" ]

[tool.poetry.dev-dependencies]
black = { version = "18.9b0", optional = true }
18 changes: 18 additions & 0 deletions tests/test_poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,21 @@ def test_check_fails():
)

assert Poetry.check(content) == {"errors": [expected], "warnings": []}


def test_poetry_writes_extras_from_dev_dependencies():
poetry = Poetry.create(str(fixtures_dir / "project_with_extras"))

package = poetry.package

dev_dependencies = {}
for dep in package.dev_requires:
dev_dependencies[dep.name] = dep

black = dev_dependencies["black"]
assert black.is_optional()

assert "extras_c" in package.extras
extras_c = package.extras["extras_c"]
assert len(extras_c) == 1
assert extras_c[0].name == "black"