[Python-checkins] cpython (2.7): Issue #7367: Add test case to test_pkgutil for walking path with

ned.deily python-checkins at python.org
Thu Oct 6 23:43:07 CEST 2011


http://hg.python.org/cpython/rev/096b010ae90b
changeset:   72769:096b010ae90b
branch:      2.7
user:        Ned Deily <nad at acm.org>
date:        Thu Oct 06 14:17:41 2011 -0700
summary:
  Issue #7367: Add test case to test_pkgutil for walking path with
an unreadable directory.

files:
  Lib/test/test_pkgutil.py |  11 +++++++++++
  1 files changed, 11 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py
--- a/Lib/test/test_pkgutil.py
+++ b/Lib/test/test_pkgutil.py
@@ -78,6 +78,17 @@
 
         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):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list