File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed
Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,19 @@ def tempdir_as_cwd():
4747 yield tmp
4848
4949
50- class SiteDir :
50+ class Fixtures :
5151 def setUp (self ):
5252 self .fixtures = ExitStack ()
5353 self .addCleanup (self .fixtures .close )
54+
55+
56+ class SiteDir (Fixtures ):
57+ def setUp (self ):
58+ super (SiteDir , self ).setUp ()
5459 self .site_dir = self .fixtures .enter_context (tempdir ())
5560
5661
57- class OnSysPath :
62+ class OnSysPath ( Fixtures ) :
5863 @staticmethod
5964 @contextlib .contextmanager
6065 def add_sys_path (dir ):
Original file line number Diff line number Diff line change 88import unittest
99import importlib
1010import importlib_metadata
11+ import pyfakefs .fake_filesystem_unittest as ffs
1112
1213from . import fixtures
1314from .. import (
@@ -193,6 +194,33 @@ def test_egg(self):
193194 version ('foo' )
194195
195196
197+ class MissingSysPath (fixtures .OnSysPath , unittest .TestCase ):
198+ site_dir = '/does-not-exist'
199+
200+ def test_discovery (self ):
201+ """
202+ Discovering distributions should succeed even if
203+ there is an invalid path on sys.path.
204+ """
205+ importlib_metadata .distributions ()
206+
207+
208+ class InaccessibleSysPath (fixtures .OnSysPath , ffs .TestCase ):
209+ site_dir = '/access-denied'
210+
211+ def setUp (self ):
212+ super (InaccessibleSysPath , self ).setUp ()
213+ self .setUpPyfakefs ()
214+ self .fs .create_dir (self .site_dir , perm_bits = 000 )
215+
216+ def test_discovery (self ):
217+ """
218+ Discovering distributions should succeed even if
219+ there is an invalid path on sys.path.
220+ """
221+ list (importlib_metadata .distributions ())
222+
223+
196224class TestEntryPoints (unittest .TestCase ):
197225 def __init__ (self , * args ):
198226 super (TestEntryPoints , self ).__init__ (* args )
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ passenv =
2828deps =
2929 cov,diffcov: coverage>=4.5
3030 diffcov: diff_cover
31+ pyfakefs
3132setenv =
3233 cov: COVERAGE_PROCESS_START ={[coverage]rcfile}
3334 cov: COVERAGE_OPTIONS =" -p"
You can’t perform that action at this time.
0 commit comments