[pypy-commit] pypy py3.5: -A tests should not import random pypy.module.XXX (partial backout of 421d7a728d21)

rlamy pypy.commits at gmail.com
Thu Jun 8 12:05:54 EDT 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r91574:f7455164661f
Date: 2017-06-08 17:05 +0100
http://bitbucket.org/pypy/pypy/changeset/f7455164661f/

Log:	-A tests should not import random pypy.module.XXX (partial backout
	of 421d7a728d21)

diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -22,6 +22,14 @@
 pypyroot = os.path.dirname(pypydir)
 
 
+RENAMED_USEMODULES = {
+    '_winreg': 'winreg',
+    'exceptions': 'builtins',
+    'struct': '_struct',
+    'thread': '_thread',
+    'operator': '_operator',
+    'signal': '_signal'}
+
 class AppError(Exception):
     def __init__(self, excinfo):
         self.excinfo = excinfo
@@ -57,8 +65,7 @@
 
 
 def _rename_module(name):
-    mod = __import__("pypy.module." + name, globals(), locals(), ['Module'])
-    return mod.Module.applevel_name or name
+    return str(RENAMED_USEMODULES.get(name, name))
 
 
 def run_with_python(python_, target_, usemodules, **definitions):


More information about the pypy-commit mailing list