@@ -92,6 +92,62 @@ def test_install_report_index(script: PipTestEnvironment, tmp_path: Path) -> Non
92
92
assert "requires_dist" in paste_report ["metadata" ]
93
93
94
94
95
+ @pytest .mark .network
96
+ def test_install_report_direct_index (script : PipTestEnvironment , shared_data : TestData , tmp_path : Path ) -> None :
97
+ """Compare report for sdist obtained via direct url and sdist obtained from index"""
98
+ report_direct_path = tmp_path / "report.json"
99
+ package = shared_data .root / "packages" / "mypy-0.782-py3-none-any.whl"
100
+ script .pip (
101
+ "install" ,
102
+ "--dry-run" ,
103
+ f"{ package } [dmypy]" ,
104
+ "--report" ,
105
+ str (report_direct_path ),
106
+ )
107
+ report_direct = json .loads (report_direct_path .read_text ())
108
+
109
+ report_index_path = tmp_path / "report.json"
110
+ script .pip (
111
+ "install" ,
112
+ "--dry-run" ,
113
+ f"mypy[dmypy]==0.782" ,
114
+ "--report" ,
115
+ str (report_index_path ),
116
+ )
117
+ report_index = json .loads (report_index_path .read_text ())
118
+
119
+ assert len (report_direct ["install" ]) == len (report_index ["install" ])
120
+ for (direct , index ) in zip (report_direct ["install" ], report_index ["install" ]):
121
+ name = direct ['metadata' ]['name' ]
122
+ assert name == index ['metadata' ]['name' ]
123
+ if name != "mypy" :
124
+ continue
125
+
126
+ assert direct ["is_direct" ] == True
127
+ assert index ["is_direct" ] == False
128
+ del direct ["is_direct" ]
129
+ del index ["is_direct" ]
130
+
131
+ assert direct ["download_info" ]["url" ].startswith ("file://" )
132
+ assert index ["download_info" ]["url" ].startswith ("https://" )
133
+ del direct ["download_info" ]["url" ]
134
+ del index ["download_info" ]["url" ]
135
+
136
+ # TODO: Is this intended behaviour? 'hash' is equal, 'hashes' is missing
137
+ # in direct installs.
138
+ # assert "hashes" not in direct["download_info"]["archive_info"]
139
+ # assert "hashes" in index["download_info"]["archive_info"]
140
+ # del index["download_info"]["archive_info"]["hashes"]
141
+
142
+ # TODO: this would be required to pass with pip 23.0.1, see
143
+ # https://github.com/pypa/pip/issues/11946
144
+ # assert "requested_extras" not in direct
145
+ # assert index["requested_extras"] == ['dmypy']
146
+ # del index["requested_extras"]
147
+
148
+ assert direct == index
149
+
150
+
95
151
@pytest .mark .network
96
152
def test_install_report_vcs_and_wheel_cache (
97
153
script : PipTestEnvironment , tmp_path : Path
0 commit comments