From efc135901ceebb3ff71dc399888a2faef2d302ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:31:35 +0200 Subject: [PATCH] fix(cache clear): normalize package name --- src/poetry/console/commands/cache/clear.py | 3 ++- tests/console/commands/cache/test_clear.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/poetry/console/commands/cache/clear.py b/src/poetry/console/commands/cache/clear.py index dc72460ef40..6134bf202f0 100644 --- a/src/poetry/console/commands/cache/clear.py +++ b/src/poetry/console/commands/cache/clear.py @@ -4,6 +4,7 @@ from cleo.helpers import argument from cleo.helpers import option +from packaging.utils import canonicalize_name from poetry.config.config import Config from poetry.console.commands.command import Command @@ -66,7 +67,7 @@ def handle(self) -> int: "Add a specific version to clear" ) elif len(parts) == 3: - package = parts[1] + package = canonicalize_name(parts[1]) version = parts[2] if not cache.has(f"{package}:{version}"): diff --git a/tests/console/commands/cache/test_clear.py b/tests/console/commands/cache/test_clear.py index ce0243f4ac8..a8fd85c876c 100644 --- a/tests/console/commands/cache/test_clear.py +++ b/tests/console/commands/cache/test_clear.py @@ -55,12 +55,16 @@ def test_cache_clear_all_no( assert cache.has("cleo:0.2") +@pytest.mark.parametrize("package_name", ["cachy", "Cachy"]) def test_cache_clear_pkg( tester: ApplicationTester, repository_one: str, cache: CacheManager, + package_name: str, ): - exit_code = tester.execute(f"cache clear {repository_one}:cachy:0.1", inputs="yes") + exit_code = tester.execute( + f"cache clear {repository_one}:{package_name}:0.1", inputs="yes" + ) assert exit_code == 0 assert tester.io.fetch_output() == ""