[pypy-commit] pypy py3.3: Fix test_pyc_commandline_argument() by creating the .pyc file with the same python executable app_main.py is run with. Also check for correct output.
mjacob
pypy.commits at gmail.com
Fri Feb 12 14:38:44 EST 2016
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.3
Changeset: r82191:bba9ea8739cc
Date: 2016-02-12 20:36 +0100
http://bitbucket.org/pypy/pypy/changeset/bba9ea8739cc/
Log: Fix test_pyc_commandline_argument() by creating the .pyc file with
the same python executable app_main.py is run with. Also check for
correct output.
diff --git a/pypy/interpreter/test/test_app_main.py b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -37,21 +37,11 @@
def getscript_pyc(space, source):
p = _get_next_path()
p.write(str(py.code.Source(source)))
- w_dir = space.wrap(str(p.dirpath()))
- w_modname = space.wrap(p.purebasename)
- space.appexec([w_dir, w_modname], """(dir, modname):
- import sys
- d = sys.modules.copy()
- sys.path.insert(0, dir)
- __import__(modname)
- sys.path.pop(0)
- for key in list(sys.modules.keys()):
- if key not in d:
- del sys.modules[key]
- """)
+ subprocess.check_call([python3, "-c", "import " + p.purebasename],
+ env={'PYTHONPATH': str(p.dirpath())})
# the .pyc file should have been created above
pycache = p.dirpath('__pycache__')
- pycs = pycache.listdir(p.basename + '*.pyc')
+ pycs = pycache.listdir(p.purebasename + '*.pyc')
assert len(pycs) == 1
return str(pycs[0])
@@ -926,7 +916,7 @@
p = getscript_pyc(self.space, "print(6*7)\n")
assert os.path.isfile(p) and p.endswith('.pyc')
data = self.run(p)
- assert data == 'in _run_compiled_module\n'
+ assert data == '42\n'
def test_main_in_dir_commandline_argument(self):
if not hasattr(runpy, '_run_module_as_main'):
More information about the pypy-commit
mailing list