Skip to content

Commit 3059d88

Browse files
authored
Use package.pretty_name in poetry version (#8849)
1 parent 022308e commit 3059d88

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/poetry/console/commands/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def handle(self) -> int:
8686
self.line(self.poetry.package.pretty_version)
8787
else:
8888
self.line(
89-
f"<comment>{self.poetry.package.name}</>"
89+
f"<comment>{self.poetry.package.pretty_name}</>"
9090
f" <info>{self.poetry.package.pretty_version}</>"
9191
)
9292

tests/console/commands/test_version.py

+23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
if TYPE_CHECKING:
1111
from cleo.testers.command_tester import CommandTester
1212

13+
from poetry.poetry import Poetry
1314
from tests.types import CommandTesterFactory
15+
from tests.types import FixtureDirGetter
16+
from tests.types import ProjectFactory
1417

1518

1619
@pytest.fixture()
@@ -23,6 +26,18 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
2326
return command_tester_factory("version")
2427

2528

29+
@pytest.fixture
30+
def poetry_with_underscore(
31+
project_factory: ProjectFactory, fixture_dir: FixtureDirGetter
32+
) -> Poetry:
33+
source = fixture_dir("simple_project")
34+
pyproject_content = (source / "pyproject.toml").read_text(encoding="utf-8")
35+
pyproject_content = pyproject_content.replace("simple-project", "simple_project")
36+
return project_factory(
37+
"project_with_underscore", pyproject_content=pyproject_content
38+
)
39+
40+
2641
@pytest.mark.parametrize(
2742
"version, rule, expected",
2843
[
@@ -79,6 +94,14 @@ def test_version_show(tester: CommandTester) -> None:
7994
assert tester.io.fetch_output() == "simple-project 1.2.3\n"
8095

8196

97+
def test_version_show_with_underscore(
98+
command_tester_factory: CommandTesterFactory, poetry_with_underscore: Poetry
99+
) -> None:
100+
tester = command_tester_factory("version", poetry=poetry_with_underscore)
101+
tester.execute()
102+
assert tester.io.fetch_output() == "simple_project 1.2.3\n"
103+
104+
82105
def test_short_version_show(tester: CommandTester) -> None:
83106
tester.execute("--short")
84107
assert tester.io.fetch_output() == "1.2.3\n"

0 commit comments

Comments
 (0)