Skip to content

Commit

Permalink
test_compare_imports_to_dependencies: Add test case suggested by Maria
Browse files Browse the repository at this point in the history
This verifies that deps declared with only case differences ("Pip" vs
"pip", which is interpreted as the _same_ package by "pip install")
still end up being reported as two different unused dependencies.
  • Loading branch information
jherland committed Mar 3, 2023
1 parent 22acf84 commit 1ecaab4
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/test_compare_imports_to_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from fawltydeps.check import LocalPackageLookup, compare_imports_to_dependencies
from fawltydeps.settings import Settings
from fawltydeps.types import (
DeclaredDependency,
DependenciesMapping,
Location,
Package,
Expand Down Expand Up @@ -101,10 +102,10 @@ def unused_factory(*deps: str) -> List[UnusedDependency]:
),
pytest.param(
[],
deps_factory("black"),
["black"],
deps_factory("pip"),
["pip"],
[],
(resolved_factory("black"), [], []),
(resolved_factory("pip"), [], []),
id="one_ignored_and_unused_dep__not_reported_as_unused",
),
pytest.param(
Expand Down Expand Up @@ -183,6 +184,31 @@ def unused_factory(*deps: str) -> List[UnusedDependency]:
),
id="mixed_dependencies__report_only_non_ignored_unused_and_non_ignored_undeclared",
),
pytest.param(
[],
[
DeclaredDependency(
name="Pip", source=Location(Path("requirements1.txt"))
),
DeclaredDependency(
name="pip", source=Location(Path("requirements2.txt"))
),
],
[],
[],
(
{
"Pip": Package("pip", {DependenciesMapping.LOCAL_ENV: {"pip"}}),
"pip": Package("pip", {DependenciesMapping.LOCAL_ENV: {"pip"}}),
},
[],
[
UnusedDependency("Pip", [Location(Path("requirements1.txt"))]),
UnusedDependency("pip", [Location(Path("requirements2.txt"))]),
],
),
id="deps_with_diff_name_for_the_same_import",
),
],
)
def test_compare_imports_to_dependencies(
Expand Down

0 comments on commit 1ecaab4

Please sign in to comment.