Author: Amaury Forgeot d'Arc <amaur...@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): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit