Author: Antonio Cuni <anto.c...@gmail.com> Branch: py3k Changeset: r52423:aaee3698b598 Date: 2012-02-13 11:35 +0100 http://bitbucket.org/pypy/pypy/changeset/aaee3698b598/
Log: improve the raises() function which is used inside -A tests. Now test_raises -A passes on cpython3 diff --git a/pypy/conftest.py b/pypy/conftest.py --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -200,14 +200,18 @@ def run_with_python(python, target): if python is None: py.test.skip("Cannot find the default python3 interpreter to run with -A") - helpers = """if 1: + helpers = r"""if 1: def skip(message): print(message) raise SystemExit(0) def raises(exc, func, *args, **kwargs): try: if isinstance(func, str): - exec("if 1:\\n" + func) + if func.startswith(" ") or func.startswith("\n"): + # it's probably an indented block, so we prefix if True: + # to avoid SyntaxError + func = "if True:\n" + func + exec(func) else: func(*args, **kwargs) except exc: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit