]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #7367: Add test case to test_pkgutil for walking path with
authorNed Deily <nad@acm.org>
Thu, 6 Oct 2011 21:19:06 +0000 (14:19 -0700)
committerNed Deily <nad@acm.org>
Thu, 6 Oct 2011 21:19:06 +0000 (14:19 -0700)
an unreadable directory.

Lib/test/test_pkgutil.py

index f69af5a86bfcd08f5cd733211217c21a18258716..f755e674649a78fb72d0c47e60b158b690efa5e1 100644 (file)
@@ -84,6 +84,17 @@ class PkgutilTests(unittest.TestCase):
 
         del sys.modules[pkg]
 
+    def test_unreadable_dir_on_syspath(self):
+        # issue7367 - walk_packages failed if unreadable dir on sys.path
+        package_name = "unreadable_package"
+        d = os.path.join(self.dirname, package_name)
+        # this does not appear to create an unreadable dir on Windows
+        #   but the test should not fail anyway
+        os.mkdir(d, 0)
+        for t in pkgutil.walk_packages(path=[self.dirname]):
+            self.fail("unexpected package found")
+        os.rmdir(d)
+
 class PkgutilPEP302Tests(unittest.TestCase):
 
     class MyTestLoader(object):