From ac6874c4bb3b7123e395d24d209658129aa63b40 Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Thu, 6 Oct 2011 14:17:41 -0700 Subject: [PATCH] Issue #7367: Add test case to test_pkgutil for walking path with an unreadable directory. --- Lib/test/test_pkgutil.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index b3fc5d84e7..3b743a8e99 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -78,6 +78,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): -- 2.50.1