[pypy-commit] pypy py3k: having the correct PYTHONPATH is required by more tests, so move the logic in _spawn

antocuni noreply at buildbot.pypy.org
Thu Jun 7 22:10:07 CEST 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r55482:c5bcc6709593
Date: 2012-06-07 15:59 +0200
http://bitbucket.org/pypy/pypy/changeset/c5bcc6709593/

Log:	having the correct PYTHONPATH is required by more tests, so move the
	logic in _spawn

diff --git a/pypy/translator/goal/test2/test_app_main.py b/pypy/translator/goal/test2/test_app_main.py
--- a/pypy/translator/goal/test2/test_app_main.py
+++ b/pypy/translator/goal/test2/test_app_main.py
@@ -229,7 +229,14 @@
         return child
 
     def spawn(self, argv):
-        return self._spawn(python3, [app_main] + argv)
+        # make sure that when we do 'import pypy' we get the correct package
+        rootdir = os.path.dirname(autopath.pypydir)
+        old_pythonpath = os.environ['PYTHONPATH']
+        os.environ['PYTHONPATH'] = rootdir
+        try:
+            return self._spawn(python3, [app_main] + argv)
+        finally:
+            os.environ['PYTHONPATH'] = old_pythonpath
 
     def test_interactive(self):
         child = self.spawn([])
@@ -415,14 +422,11 @@
         child.expect('789')    # expect to see it before the timeout hits
         child.sendline('X')
 
-    def test_options_i_m(self, monkeypatch):
+    def test_options_i_m(self):
         if sys.platform == "win32":
             skip("close_fds is not supported on Windows platforms")
         if not hasattr(runpy, '_run_module_as_main'):
             skip("requires CPython >= 2.6")
-        # make sure that when we do 'import pypy' we get the correct package
-        rootdir = os.path.dirname(autopath.pypydir)
-        monkeypatch.setenv('PYTHONPATH', rootdir)
         p = os.path.join(autopath.this_dir, 'mymodule.py')
         p = os.path.abspath(p)
         child = self.spawn(['-i',


More information about the pypy-commit mailing list