summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib/test_main.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-02-12 02:58:47 (GMT)
committerGitHub <noreply@github.com>2020-02-12 02:58:47 (GMT)
commite5bd73632e77dc5ab0cab77e48e94ca5e354be8a (patch)
tree714f30a26206aeec8fd331b42ae095b638f216e5 /Lib/test/test_importlib/test_main.py
parente6be9b59a911626d6597fe148c32f0342bd2bd24 (diff)
downloadcpython-e5bd73632e77dc5ab0cab77e48e94ca5e354be8a.zip
cpython-e5bd73632e77dc5ab0cab77e48e94ca5e354be8a.tar.gz
cpython-e5bd73632e77dc5ab0cab77e48e94ca5e354be8a.tar.bz2
bpo-39595: Improve zipfile.Path performance (#18406)
* Improve zipfile.Path performance on zipfiles with a large number of entries. * 📜🤖 Added by blurb_it. * Add bpo to blurb * Sync with importlib_metadata 1.5 (6fe70ca) * Update blurb. * Remove compatibility code * Add stubs module, omitted from earlier commit Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_importlib/test_main.py')
-rw-r--r--Lib/test/test_importlib/test_main.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/test_main.py b/Lib/test/test_importlib/test_main.py
index c5f1dbb..42a7999 100644
--- a/Lib/test/test_importlib/test_main.py
+++ b/Lib/test/test_importlib/test_main.py
@@ -7,6 +7,11 @@ import textwrap
import unittest
import importlib.metadata
+try:
+ import pyfakefs.fake_filesystem_unittest as ffs
+except ImportError:
+ from .stubs import fake_filesystem_unittest as ffs
+
from . import fixtures
from importlib.metadata import (
Distribution, EntryPoint,
@@ -185,6 +190,33 @@ class DirectoryTest(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
version('foo')
+class MissingSysPath(fixtures.OnSysPath, unittest.TestCase):
+ site_dir = '/does-not-exist'
+
+ def test_discovery(self):
+ """
+ Discovering distributions should succeed even if
+ there is an invalid path on sys.path.
+ """
+ importlib.metadata.distributions()
+
+
+class InaccessibleSysPath(fixtures.OnSysPath, ffs.TestCase):
+ site_dir = '/access-denied'
+
+ def setUp(self):
+ super(InaccessibleSysPath, self).setUp()
+ self.setUpPyfakefs()
+ self.fs.create_dir(self.site_dir, perm_bits=000)
+
+ def test_discovery(self):
+ """
+ Discovering distributions should succeed even if
+ there is an invalid path on sys.path.
+ """
+ list(importlib.metadata.distributions())
+
+
class TestEntryPoints(unittest.TestCase):
def __init__(self, *args):
super(TestEntryPoints, self).__init__(*args)