[Python-checkins] cpython (3.2): Issue #7367: Ensure test directory always gets removed.

ned.deily python-checkins at python.org
Fri Oct 7 21:03:17 CEST 2011


http://hg.python.org/cpython/rev/ff72f76dcf43
changeset:   72799:ff72f76dcf43
branch:      3.2
parent:      72792:459f5e10cd4f
user:        Ned Deily <nad at acm.org>
date:        Fri Oct 07 12:01:40 2011 -0700
summary:
  Issue #7367: Ensure test directory always gets removed.

files:
  Lib/test/test_pkgutil.py |  4 ++--
  1 files changed, 2 insertions(+), 2 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
@@ -15,11 +15,11 @@
 
     def setUp(self):
         self.dirname = tempfile.mkdtemp()
+        self.addCleanup(shutil.rmtree, self.dirname)
         sys.path.insert(0, self.dirname)
 
     def tearDown(self):
         del sys.path[0]
-        shutil.rmtree(self.dirname)
 
     def test_getdata_filesys(self):
         pkg = 'test_getdata_filesys'
@@ -91,9 +91,9 @@
         # this does not appear to create an unreadable dir on Windows
         #   but the test should not fail anyway
         os.mkdir(d, 0)
+        self.addCleanup(os.rmdir, d)
         for t in pkgutil.walk_packages(path=[self.dirname]):
             self.fail("unexpected package found")
-        os.rmdir(d)
 
 class PkgutilPEP302Tests(unittest.TestCase):
 

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


More information about the Python-checkins mailing list