@@ -188,6 +188,7 @@ def test_noegglink_in_sitepkgs_venv_global(self):
188
188
assert egg_link_path (self .mock_dist ) is None
189
189
190
190
191
+ @patch ('pip._internal.utils.misc.dist_in_curr_dir' )
191
192
@patch ('pip._internal.utils.misc.dist_in_usersite' )
192
193
@patch ('pip._internal.utils.misc.dist_is_local' )
193
194
@patch ('pip._internal.utils.misc.dist_is_editable' )
@@ -199,6 +200,7 @@ class Tests_get_installed_distributions:
199
200
Mock (test_name = "editable" ),
200
201
Mock (test_name = "normal" ),
201
202
Mock (test_name = "user" ),
203
+ Mock (test_name = "curr_dir" )
202
204
]
203
205
204
206
workingset_stdlib = [
@@ -221,45 +223,56 @@ def dist_is_local(self, dist):
221
223
def dist_in_usersite (self , dist ):
222
224
return dist .test_name == "user"
223
225
226
+ def dist_in_curr_dir (self , dist ):
227
+ return dist .test_name == "curr_dir"
228
+
224
229
@patch ('pip._vendor.pkg_resources.working_set' , workingset )
225
230
def test_editables_only (self , mock_dist_is_editable ,
226
231
mock_dist_is_local ,
227
- mock_dist_in_usersite ):
232
+ mock_dist_in_usersite ,
233
+ mock_dist_in_curr_dir ):
228
234
mock_dist_is_editable .side_effect = self .dist_is_editable
229
235
mock_dist_is_local .side_effect = self .dist_is_local
230
236
mock_dist_in_usersite .side_effect = self .dist_in_usersite
237
+ mock_dist_in_curr_dir .side_effect = self .dist_in_curr_dir
231
238
dists = get_installed_distributions (editables_only = True )
232
239
assert len (dists ) == 1 , dists
233
240
assert dists [0 ].test_name == "editable"
234
241
235
242
@patch ('pip._vendor.pkg_resources.working_set' , workingset )
236
243
def test_exclude_editables (self , mock_dist_is_editable ,
237
244
mock_dist_is_local ,
238
- mock_dist_in_usersite ):
245
+ mock_dist_in_usersite ,
246
+ mock_dist_in_curr_dir ):
239
247
mock_dist_is_editable .side_effect = self .dist_is_editable
240
248
mock_dist_is_local .side_effect = self .dist_is_local
241
249
mock_dist_in_usersite .side_effect = self .dist_in_usersite
250
+ mock_dist_in_curr_dir .side_effect = self .dist_in_curr_dir
242
251
dists = get_installed_distributions (include_editables = False )
243
252
assert len (dists ) == 1
244
253
assert dists [0 ].test_name == "normal"
245
254
246
255
@patch ('pip._vendor.pkg_resources.working_set' , workingset )
247
256
def test_include_globals (self , mock_dist_is_editable ,
248
257
mock_dist_is_local ,
249
- mock_dist_in_usersite ):
258
+ mock_dist_in_usersite ,
259
+ mock_dist_in_curr_dir ):
250
260
mock_dist_is_editable .side_effect = self .dist_is_editable
251
261
mock_dist_is_local .side_effect = self .dist_is_local
252
262
mock_dist_in_usersite .side_effect = self .dist_in_usersite
263
+ mock_dist_in_curr_dir .side_effect = self .dist_in_curr_dir
253
264
dists = get_installed_distributions (local_only = False )
254
265
assert len (dists ) == 4
255
266
256
267
@patch ('pip._vendor.pkg_resources.working_set' , workingset )
257
268
def test_user_only (self , mock_dist_is_editable ,
258
269
mock_dist_is_local ,
259
- mock_dist_in_usersite ):
270
+ mock_dist_in_usersite ,
271
+ mock_dist_in_curr_dir ):
260
272
mock_dist_is_editable .side_effect = self .dist_is_editable
261
273
mock_dist_is_local .side_effect = self .dist_is_local
262
274
mock_dist_in_usersite .side_effect = self .dist_in_usersite
275
+ mock_dist_in_curr_dir .side_effect = self .dist_in_curr_dir
263
276
dists = get_installed_distributions (local_only = False ,
264
277
user_only = True )
265
278
assert len (dists ) == 1
@@ -268,20 +281,24 @@ def test_user_only(self, mock_dist_is_editable,
268
281
@patch ('pip._vendor.pkg_resources.working_set' , workingset_stdlib )
269
282
def test_gte_py27_excludes (self , mock_dist_is_editable ,
270
283
mock_dist_is_local ,
271
- mock_dist_in_usersite ):
284
+ mock_dist_in_usersite ,
285
+ mock_dist_in_curr_dir ):
272
286
mock_dist_is_editable .side_effect = self .dist_is_editable
273
287
mock_dist_is_local .side_effect = self .dist_is_local
274
288
mock_dist_in_usersite .side_effect = self .dist_in_usersite
289
+ mock_dist_in_curr_dir .side_effect = self .dist_in_curr_dir
275
290
dists = get_installed_distributions ()
276
291
assert len (dists ) == 0
277
292
278
293
@patch ('pip._vendor.pkg_resources.working_set' , workingset_freeze )
279
294
def test_freeze_excludes (self , mock_dist_is_editable ,
280
295
mock_dist_is_local ,
281
- mock_dist_in_usersite ):
296
+ mock_dist_in_usersite ,
297
+ mock_dist_in_curr_dir ):
282
298
mock_dist_is_editable .side_effect = self .dist_is_editable
283
299
mock_dist_is_local .side_effect = self .dist_is_local
284
300
mock_dist_in_usersite .side_effect = self .dist_in_usersite
301
+ mock_dist_in_curr_dir .side_effect = self .dist_in_curr_dir
285
302
dists = get_installed_distributions (
286
303
skip = ('setuptools' , 'pip' , 'distribute' ))
287
304
assert len (dists ) == 0
0 commit comments