[pypy-commit] pypy py3k: Fixes for applevel tests in sys modules:
amauryfa
noreply at buildbot.pypy.org
Thu Feb 21 00:33:39 CET 2013
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r61507:89fa26e89071
Date: 2013-02-21 00:33 +0100
http://bitbucket.org/pypy/pypy/changeset/89fa26e89071/
Log: Fixes for applevel tests in sys modules: put test code in a function
with a the same name.
Also add the traceback to the assertion message.
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
@@ -118,16 +118,20 @@
defs.append("self.%s = %s\n" % (symbol, py3k_repr(value)))
source = py.code.Source(target_)[1:]
pyfile = udir.join('src.py')
- source = helpers + '\n'.join(defs) + 'if 1:\n' + str(source)
+ target_name = target_.__name__
with pyfile.open('w') as f:
- f.write(source)
+ f.write(helpers)
+ f.write('\n'.join(defs))
+ f.write('def %s():\n' % target_name)
+ f.write(str(source))
+ f.write("\n%s()\n" % target_name)
res, stdout, stderr = runsubprocess.run_subprocess(
python_, [str(pyfile)])
- print source
+ print pyfile.read()
print >> sys.stdout, stdout
print >> sys.stderr, stderr
if res > 0:
- raise AssertionError("Subprocess failed")
+ raise AssertionError("Subprocess failed:\n" + stderr)
def extract_docstring_if_empty_function(fn):
More information about the pypy-commit
mailing list