30
30
egg_link_path ,
31
31
format_size ,
32
32
get_distribution ,
33
- get_installed_distributions ,
34
33
get_prog ,
35
34
hide_url ,
36
35
hide_value ,
@@ -186,9 +185,8 @@ def test_noegglink_in_sitepkgs_venv_global(self):
186
185
187
186
@patch ('pip._internal.utils.misc.dist_in_usersite' )
188
187
@patch ('pip._internal.utils.misc.dist_is_local' )
189
- @patch ('pip._internal.utils.misc.dist_is_editable' )
190
188
class TestsGetDistributions :
191
- """Test get_installed_distributions() and get_distribution().
189
+ """Test get_distribution().
192
190
"""
193
191
class MockWorkingSet (list ):
194
192
def require (self , name ):
@@ -212,80 +210,12 @@ def require(self, name):
212
210
Mock (test_name = 'normal' , project_name = 'distribute' )
213
211
))
214
212
215
- def dist_is_editable (self , dist ):
216
- return dist .test_name == "editable"
217
-
218
213
def dist_is_local (self , dist ):
219
214
return dist .test_name != "global" and dist .test_name != 'user'
220
215
221
216
def dist_in_usersite (self , dist ):
222
217
return dist .test_name == "user"
223
218
224
- @patch ('pip._vendor.pkg_resources.working_set' , workingset )
225
- def test_editables_only (self , mock_dist_is_editable ,
226
- mock_dist_is_local ,
227
- mock_dist_in_usersite ):
228
- mock_dist_is_editable .side_effect = self .dist_is_editable
229
- mock_dist_is_local .side_effect = self .dist_is_local
230
- mock_dist_in_usersite .side_effect = self .dist_in_usersite
231
- dists = get_installed_distributions (editables_only = True )
232
- assert len (dists ) == 1 , dists
233
- assert dists [0 ].test_name == "editable"
234
-
235
- @patch ('pip._vendor.pkg_resources.working_set' , workingset )
236
- def test_exclude_editables (self , mock_dist_is_editable ,
237
- mock_dist_is_local ,
238
- mock_dist_in_usersite ):
239
- mock_dist_is_editable .side_effect = self .dist_is_editable
240
- mock_dist_is_local .side_effect = self .dist_is_local
241
- mock_dist_in_usersite .side_effect = self .dist_in_usersite
242
- dists = get_installed_distributions (include_editables = False )
243
- assert len (dists ) == 1
244
- assert dists [0 ].test_name == "normal"
245
-
246
- @patch ('pip._vendor.pkg_resources.working_set' , workingset )
247
- def test_include_globals (self , mock_dist_is_editable ,
248
- mock_dist_is_local ,
249
- mock_dist_in_usersite ):
250
- mock_dist_is_editable .side_effect = self .dist_is_editable
251
- mock_dist_is_local .side_effect = self .dist_is_local
252
- mock_dist_in_usersite .side_effect = self .dist_in_usersite
253
- dists = get_installed_distributions (local_only = False )
254
- assert len (dists ) == 4
255
-
256
- @patch ('pip._vendor.pkg_resources.working_set' , workingset )
257
- def test_user_only (self , mock_dist_is_editable ,
258
- mock_dist_is_local ,
259
- mock_dist_in_usersite ):
260
- mock_dist_is_editable .side_effect = self .dist_is_editable
261
- mock_dist_is_local .side_effect = self .dist_is_local
262
- mock_dist_in_usersite .side_effect = self .dist_in_usersite
263
- dists = get_installed_distributions (local_only = False ,
264
- user_only = True )
265
- assert len (dists ) == 1
266
- assert dists [0 ].test_name == "user"
267
-
268
- @patch ('pip._vendor.pkg_resources.working_set' , workingset_stdlib )
269
- def test_gte_py27_excludes (self , mock_dist_is_editable ,
270
- mock_dist_is_local ,
271
- mock_dist_in_usersite ):
272
- mock_dist_is_editable .side_effect = self .dist_is_editable
273
- mock_dist_is_local .side_effect = self .dist_is_local
274
- mock_dist_in_usersite .side_effect = self .dist_in_usersite
275
- dists = get_installed_distributions ()
276
- assert len (dists ) == 0
277
-
278
- @patch ('pip._vendor.pkg_resources.working_set' , workingset_freeze )
279
- def test_freeze_excludes (self , mock_dist_is_editable ,
280
- mock_dist_is_local ,
281
- mock_dist_in_usersite ):
282
- mock_dist_is_editable .side_effect = self .dist_is_editable
283
- mock_dist_is_local .side_effect = self .dist_is_local
284
- mock_dist_in_usersite .side_effect = self .dist_in_usersite
285
- dists = get_installed_distributions (
286
- skip = ('setuptools' , 'pip' , 'distribute' ))
287
- assert len (dists ) == 0
288
-
289
219
@pytest .mark .parametrize (
290
220
"working_set, req_name" ,
291
221
itertools .chain (
@@ -301,15 +231,13 @@ def test_freeze_excludes(self, mock_dist_is_editable,
301
231
)
302
232
def test_get_distribution (
303
233
self ,
304
- mock_dist_is_editable ,
305
234
mock_dist_is_local ,
306
235
mock_dist_in_usersite ,
307
236
working_set ,
308
237
req_name ,
309
238
):
310
239
"""Ensure get_distribution() finds all kinds of distributions.
311
240
"""
312
- mock_dist_is_editable .side_effect = self .dist_is_editable
313
241
mock_dist_is_local .side_effect = self .dist_is_local
314
242
mock_dist_in_usersite .side_effect = self .dist_in_usersite
315
243
with patch ("pip._vendor.pkg_resources.working_set" , working_set ):
@@ -320,11 +248,9 @@ def test_get_distribution(
320
248
@patch ('pip._vendor.pkg_resources.working_set' , workingset )
321
249
def test_get_distribution_nonexist (
322
250
self ,
323
- mock_dist_is_editable ,
324
251
mock_dist_is_local ,
325
252
mock_dist_in_usersite ,
326
253
):
327
- mock_dist_is_editable .side_effect = self .dist_is_editable
328
254
mock_dist_is_local .side_effect = self .dist_is_local
329
255
mock_dist_in_usersite .side_effect = self .dist_in_usersite
330
256
dist = get_distribution ("non-exist" )
0 commit comments