Skip to content

Commit df7a82d

Browse files
authored
Use MockGraph type alias in tests (#462)
1 parent 9c46b0f commit df7a82d

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

tests/_models/test_dag.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_package_dag_from_pkgs(mock_pkgs: Callable[[MockGraph], Iterator[Mock]])
112112
# when pip's _vendor.packaging.requirements.Requirement's requires() gives a lowercased package name but the actual
113113
# package name in PyPI is mixed case, expect the mixed case version
114114

115-
graph: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] = {
115+
graph: MockGraph = {
116116
("examplePy", "1.2.3"): [("hellopy", [(">=", "2.0.0")])],
117117
("HelloPy", "2.2.0"): [],
118118
}
@@ -126,7 +126,7 @@ def test_package_dag_from_pkgs(mock_pkgs: Callable[[MockGraph], Iterator[Mock]])
126126
def test_package_dag_from_pkgs_uses_pep503normalize(mock_pkgs: Callable[[MockGraph], Iterator[Mock]]) -> None:
127127
# ensure that requirement gets matched with a dists even when it's key needs pep503 normalization to match
128128

129-
graph: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] = {
129+
graph: MockGraph = {
130130
("parent-package", "1.2.3"): [("flufl.lock", [(">=", "2.0.0")])],
131131
("flufl-lock", "2.2.0"): [],
132132
}
@@ -140,7 +140,7 @@ def test_package_dag_from_pkgs_uses_pep503normalize(mock_pkgs: Callable[[MockGra
140140
def test_package_from_pkgs_given_invalid_requirements(
141141
mock_pkgs: Callable[[MockGraph], Iterator[Mock]], capfd: pytest.CaptureFixture[str]
142142
) -> None:
143-
graph: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] = {
143+
graph: MockGraph = {
144144
("a-package", "1.2.3"): [("BAD**requirement", [(">=", "2.0.0")])],
145145
}
146146
package_dag = PackageDAG.from_pkgs(list(mock_pkgs(graph)))

tests/render/test_json_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_json_tree_given_req_package_with_version_spec(
2626
version_spec_tuple: tuple[str, str],
2727
expected_version_spec: str,
2828
) -> None:
29-
graph: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] = {
29+
graph: MockGraph = {
3030
("a", "1.2.3"): [("b", [version_spec_tuple])],
3131
("b", "2.2.0"): [],
3232
}

tests/render/test_text.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def test_render_text_list_all_and_packages_options_used(
446446
capsys: pytest.CaptureFixture[str],
447447
mock_pkgs: Callable[[MockGraph], Iterator[Mock]],
448448
) -> None:
449-
graph: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] = {
449+
graph: MockGraph = {
450450
("examplePy", "1.2.3"): [("hellopy", [(">=", "2.0.0")]), ("worldpy", [(">=", "0.0.2")])],
451451
("HelloPy", "2.0.0"): [],
452452
("worldpy", "0.0.2"): [],
@@ -501,7 +501,7 @@ def test_render_text_with_license_info(
501501
capsys: pytest.CaptureFixture[str],
502502
monkeypatch: pytest.MonkeyPatch,
503503
) -> None:
504-
graph: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] = {
504+
graph: MockGraph = {
505505
("a", "3.4.0"): [("c", [("==", "1.0.0")])],
506506
("b", "2.3.1"): [],
507507
("c", "1.0.0"): [],
@@ -550,7 +550,7 @@ def test_render_text_with_license_info_and_reversed_tree(
550550
capsys: pytest.CaptureFixture[str],
551551
monkeypatch: pytest.MonkeyPatch,
552552
) -> None:
553-
graph: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]] = {
553+
graph: MockGraph = {
554554
("a", "3.4.0"): [("b", [("==", "2.3.1")]), ("c", [("==", "1.0.0")])],
555555
("b", "2.3.1"): [("c", [("==", "1.0.0")])],
556556
("c", "1.0.0"): [],

tests/test_validate.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
)
7070
def test_cyclic_deps(
7171
capsys: pytest.CaptureFixture[str],
72-
mpkgs: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]],
72+
mpkgs: MockGraph,
7373
expected_keys: list[list[str]],
7474
expected_output: list[str],
7575
mock_pkgs: Callable[[MockGraph], Iterator[Mock]],
@@ -121,7 +121,7 @@ def test_cyclic_deps(
121121
)
122122
def test_conflicting_deps(
123123
capsys: pytest.CaptureFixture[str],
124-
mpkgs: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]],
124+
mpkgs: MockGraph,
125125
expected_keys: dict[str, list[str]],
126126
expected_output: list[str],
127127
mock_pkgs: Callable[[MockGraph], Iterator[Mock]],
@@ -165,7 +165,7 @@ def test_conflicting_deps(
165165
def test_validate(
166166
capsys: pytest.CaptureFixture[str],
167167
mock_pkgs: Callable[[MockGraph], Iterator[Mock]],
168-
mpkgs: dict[tuple[str, str], list[tuple[str, list[tuple[str, str]]]]],
168+
mpkgs: MockGraph,
169169
expected_output: list[str],
170170
) -> None:
171171
tree = PackageDAG.from_pkgs(list(mock_pkgs(mpkgs)))

0 commit comments

Comments
 (0)