]> granicus.if.org Git - python/commitdiff
Issue #15425: Don't rely on the assumption that the current working directory is...
authorNick Coghlan <ncoghlan@gmail.com>
Tue, 31 Jul 2012 11:39:42 +0000 (21:39 +1000)
committerNick Coghlan <ncoghlan@gmail.com>
Tue, 31 Jul 2012 11:39:42 +0000 (21:39 +1000)
Lib/test/test_import.py

index 70893284fc9b0346c99ac596ada8822242c1a58d..2e581993363e15e5fd605c0c7bbc1d00e590db65 100644 (file)
@@ -859,16 +859,14 @@ class ImportTracebackTests(unittest.TestCase):
 
     def _setup_broken_package(self, parent, child):
         pkg_name = "_parent_foo"
-        def cleanup():
-            rmtree(pkg_name)
-            unload(pkg_name)
-        os.mkdir(pkg_name)
-        self.addCleanup(cleanup)
+        self.addCleanup(unload, pkg_name)
+        pkg_path = os.path.join(TESTFN, pkg_name)
+        os.mkdir(pkg_path)
         # Touch the __init__.py
-        init_path = os.path.join(pkg_name, '__init__.py')
+        init_path = os.path.join(pkg_path, '__init__.py')
         with open(init_path, 'w') as f:
             f.write(parent)
-        bar_path = os.path.join(pkg_name, 'bar.py')
+        bar_path = os.path.join(pkg_path, 'bar.py')
         with open(bar_path, 'w') as f:
             f.write(child)
         importlib.invalidate_caches()