@@ -64,6 +64,59 @@ def test_install_report_dep(
64
64
assert _install_dict (report )["simple" ]["requested" ] is False
65
65
66
66
67
+ def test_yanked_version (
68
+ script : PipTestEnvironment , data : TestData , tmp_path : Path
69
+ ) -> None :
70
+ """
71
+ Test is_yanked is True when explicitly requesting a yanked package.
72
+ Yanked files are always ignored, unless they are the only file that
73
+ matches a version specifier that "pins" to an exact version (PEP 592).
74
+ """
75
+ report_path = tmp_path / "report.json"
76
+ script .pip (
77
+ "install" ,
78
+ "simple==3.0" ,
79
+ "--index-url" ,
80
+ data .index_url ("yanked" ),
81
+ "--dry-run" ,
82
+ "--report" ,
83
+ str (report_path ),
84
+ allow_stderr_warning = True ,
85
+ )
86
+ report = json .loads (report_path .read_text ())
87
+ simple_report = _install_dict (report )["simple" ]
88
+ assert simple_report ["requested" ] is True
89
+ assert simple_report ["is_direct" ] is False
90
+ assert simple_report ["is_yanked" ] is True
91
+ assert simple_report ["metadata" ]["version" ] == "3.0"
92
+
93
+
94
+ def test_skipped_yanked_version (
95
+ script : PipTestEnvironment , data : TestData , tmp_path : Path
96
+ ) -> None :
97
+ """
98
+ Test is_yanked is False when not explicitly requesting a yanked package.
99
+ Yanked files are always ignored, unless they are the only file that
100
+ matches a version specifier that "pins" to an exact version (PEP 592).
101
+ """
102
+ report_path = tmp_path / "report.json"
103
+ script .pip (
104
+ "install" ,
105
+ "simple" ,
106
+ "--index-url" ,
107
+ data .index_url ("yanked" ),
108
+ "--dry-run" ,
109
+ "--report" ,
110
+ str (report_path ),
111
+ )
112
+ report = json .loads (report_path .read_text ())
113
+ simple_report = _install_dict (report )["simple" ]
114
+ assert simple_report ["requested" ] is True
115
+ assert simple_report ["is_direct" ] is False
116
+ assert simple_report ["is_yanked" ] is False
117
+ assert simple_report ["metadata" ]["version" ] == "2.0"
118
+
119
+
67
120
@pytest .mark .network
68
121
def test_install_report_index (script : PipTestEnvironment , tmp_path : Path ) -> None :
69
122
"""Test report for sdist obtained from index."""
0 commit comments