[Python-checkins] cpython: Issue #15425: Don't rely on the assumption that the current working directory

nick.coghlan python-checkins at python.org
Tue Jul 31 13:39:58 CEST 2012


http://hg.python.org/cpython/rev/8a0eb395e725
changeset:   78345:8a0eb395e725
user:        Nick Coghlan <ncoghlan at gmail.com>
date:        Tue Jul 31 21:39:42 2012 +1000
summary:
  Issue #15425: Don't rely on the assumption that the current working directory is on sys.path (this will hopefully appease the XP buildbots)

files:
  Lib/test/test_import.py |  12 +++++-------
  1 files changed, 5 insertions(+), 7 deletions(-)


diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -859,16 +859,14 @@
 
     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()

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


More information about the Python-checkins mailing list