Skip to content

Commit 7f60f74

Browse files
committed
added test for stub pattern matching mapping
1 parent 6d3c78a commit 7f60f74

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/python/pants/backend/python/dependency_inference/default_module_mapping.py

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def two_groups_hyphens_two_replacements_with_suffix(
100100
],
101101
re.compile(r"""^oslo-.+"""): [all_hyphen_to_underscore],
102102
re.compile(r"""^python-(.+)"""): [first_group_hyphen_to_underscore],
103-
re.compile(r"""^python-(.+)"""): [first_group_hyphen_to_underscore],
104103
}
105104

106105
DEFAULT_MODULE_MAPPING: Dict[str, Tuple[str, ...]] = {

src/python/pants/backend/python/dependency_inference/module_mapper_test.py

+36
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,42 @@ def test_generate_mappings_from_pattern_matches_para(
985985
assert generate_mappings_from_pattern(proj_name, is_type_stub=False) == expected_modules
986986

987987

988+
@pytest.mark.parametrize(
989+
("proj_name", "expected_modules"),
990+
[
991+
(
992+
"types-requests",
993+
("requests",),
994+
),
995+
(
996+
"botocore-stubs",
997+
("botocore",),
998+
),
999+
(
1000+
"django-types",
1001+
("django",),
1002+
),
1003+
(
1004+
"types_requests",
1005+
("requests",),
1006+
),
1007+
(
1008+
"botocore_stubs",
1009+
("botocore",),
1010+
),
1011+
(
1012+
"django_types",
1013+
("django",),
1014+
),
1015+
("", tuple()),
1016+
],
1017+
)
1018+
def test_generate_type_stub_mappings_from_pattern_matches_para(
1019+
proj_name: str, expected_modules: Tuple[str]
1020+
) -> None:
1021+
assert generate_mappings_from_pattern(proj_name, is_type_stub=True) == expected_modules
1022+
1023+
9881024
def test_number_of_capture_groups_for_functions() -> None:
9891025
with pytest.raises(ValueError):
9901026
re.sub("foo", first_group_hyphen_to_underscore, "foo")

0 commit comments

Comments
 (0)