Skip to content

Commit

Permalink
show --tree: stop ignoring --no-dev (python-poetry#3296)
Browse files Browse the repository at this point in the history
  • Loading branch information
1ace authored and dsch committed Apr 23, 2021
1 parent aa8e486 commit d5eebfb
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
4 changes: 3 additions & 1 deletion poetry/console/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def handle(self):

# Show tree view if requested
if self.option("tree") and not package:
requires = self.poetry.package.requires + self.poetry.package.dev_requires
requires = self.poetry.package.requires
if include_dev:
requires += self.poetry.package.dev_requires
packages = locked_repo.packages
for package in packages:
for require in requires:
Expand Down
67 changes: 67 additions & 0 deletions tests/console/commands/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,3 +1152,70 @@ def test_show_tree(tester, poetry, installed):
"""

assert expected == tester.io.fetch_output()


def test_show_tree_no_dev(tester, poetry, installed):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0"))
poetry.package.add_dependency(
Factory.create_dependency("pytest", "^6.1.0", category="dev")
)

cachy2 = get_package("cachy", "0.2.0")
cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6"))
installed.add_package(cachy2)

pytest = get_package("pytest", "6.1.1")
installed.add_package(pytest)

poetry.locker.mock_lock_data(
{
"package": [
{
"name": "cachy",
"version": "0.2.0",
"description": "",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
"dependencies": {"msgpack-python": ">=0.5 <0.6"},
},
{
"name": "msgpack-python",
"version": "0.5.1",
"description": "",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
{
"name": "pytest",
"version": "6.1.1",
"description": "",
"category": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"cachy": [], "msgpack-python": [], "pytest": []},
},
}
)

tester.execute("--tree --no-dev")

expected = """\
cachy 0.2.0
`-- msgpack-python >=0.5 <0.6
"""

assert expected == tester.io.fetch_output()

0 comments on commit d5eebfb

Please sign in to comment.