Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r63741:7ce5e8dbcb61
Date: 2013-04-28 16:04 -0700
http://bitbucket.org/pypy/pypy/changeset/7ce5e8dbcb61/

Log:    hack hack hack around appdirect failures

diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -167,7 +167,10 @@
 def _setup(cls):
     space = cls.space
     dn = setup_directory_structure(cls)
-    return space.appexec([space.wrap(dn)], """
+    return _setup_path(space, dn)
+
+def _setup_path(space, path):
+    return space.appexec([space.wrap(path)], """
         (dn): 
             import sys
             path = list(sys.path)
@@ -573,9 +576,8 @@
         import time
         time.sleep(1)
 
-        f = open(test_reload.__file__, "w")
-        f.write("def test():\n    raise NotImplementedError\n")
-        f.close()
+        with open(test_reload.__file__, "w") as f:
+            f.write("def test():\n    raise NotImplementedError\n")
         imp.reload(test_reload)
         try:
             test_reload.test()
@@ -587,6 +589,10 @@
         import os
         os.unlink(test_reload.__file__)
 
+        # restore it for later tests
+        with open(test_reload.__file__, "w") as f:
+            f.write("def test():\n    raise ValueError\n")
+
     def test_reload_failing(self):
         import test_reload
         import time, imp
@@ -1149,11 +1155,9 @@
     def setup_class(cls):
         mydir = os.path.dirname(__file__)
         cls.w_hooktest = cls.space.wrap(os.path.join(mydir, 'hooktest'))
-        cls.space.appexec([cls.space.wrap(mydir)], """
-            (mydir):
-                import sys
-                sys.path.append(mydir)
-
+        cls.w_saved_modules = _setup_path(cls.space, mydir)
+        cls.space.appexec([], """
+            ():
                 # Obscure: manually bootstrap the utf-8/latin1 codecs
                 # for TextIOs opened by imp.find_module. It's not
                 # otherwise loaded by the test infrastructure but would
@@ -1163,11 +1167,7 @@
         """)
 
     def teardown_class(cls):
-        cls.space.appexec([], """
-            ():
-                import sys
-                sys.path.pop()
-        """)
+        _teardown(cls.space, cls.w_saved_modules)
 
     def test_meta_path(self):
         tried_imports = []
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to