[pypy-svn] pypy default: Just skip the test if no _run_module_as_main is available in cpython's runpy.

arigo commits-noreply at bitbucket.org
Tue Feb 15 09:58:50 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41940:de9f6aee5d6f
Date: 2011-02-15 09:52 +0100
http://bitbucket.org/pypy/pypy/changeset/de9f6aee5d6f/

Log:	Just skip the test if no _run_module_as_main is available in
	cpython's runpy.

diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -663,14 +663,9 @@
             return None
         else:
             return imp.NullImporter(path)
-    def _run_module_as_main(module):
-        import sys, os
-        path = os.path.join(sys.path[0], module + '.py')
-        execfile(path, {'__name__': '__main__'})
 
     imp._run_compiled_module = _run_compiled_module
     imp._getimporter = _getimporter
-    runpy._run_module_as_main = _run_module_as_main
 
     # stick the current sys.path into $PYTHONPATH, so that CPython still
     # finds its own extension modules :-/

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
@@ -3,7 +3,7 @@
 """
 from __future__ import with_statement
 import py
-import sys, os, re
+import sys, os, re, runpy
 import autopath
 from pypy.tool.udir import udir
 from contextlib import contextmanager
@@ -415,6 +415,8 @@
     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")
         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