diff --git a/_pytest/assertion/oldinterpret.py b/_pytest/assertion/oldinterpret.py index 3ca12ec2b..a90c91859 100644 --- a/_pytest/assertion/oldinterpret.py +++ b/_pytest/assertion/oldinterpret.py @@ -1,8 +1,7 @@ import py import sys, inspect from compiler import parse, ast, pycodegen -from _pytest.assertion.util import format_explanation -from _pytest.assertion.reinterpret import BuiltinAssertionError +from _pytest.assertion.util import format_explanation, BuiltinAssertionError passthroughex = py.builtin._sysex diff --git a/_pytest/assertion/reinterpret.py b/_pytest/assertion/reinterpret.py index 6e9465d8a..b0d5a6689 100644 --- a/_pytest/assertion/reinterpret.py +++ b/_pytest/assertion/reinterpret.py @@ -1,7 +1,6 @@ import sys import py - -BuiltinAssertionError = py.builtin.builtins.AssertionError +from _pytest.assertion.util import BuiltinAssertionError class AssertionError(BuiltinAssertionError): def __init__(self, *args): diff --git a/_pytest/assertion/util.py b/_pytest/assertion/util.py index a85ed99f7..c7ef6dd81 100644 --- a/_pytest/assertion/util.py +++ b/_pytest/assertion/util.py @@ -2,6 +2,7 @@ import py +BuiltinAssertionError = py.builtin.builtins.AssertionError # The _reprcompare attribute on the util module is used by the new assertion # interpretation code and assertion rewriter to detect this plugin was diff --git a/testing/test_assertinterpret.py b/testing/test_assertinterpret.py index fc456c636..bc7c55616 100644 --- a/testing/test_assertinterpret.py +++ b/testing/test_assertinterpret.py @@ -322,3 +322,18 @@ def test_assert_raises_in_nonzero_of_object_pytest_issue10(): e = exvalue() s = str(e) assert " < 0" in s + +@py.test.mark.skipif("sys.version_info >= (2,6)") +def test_oldinterpret_importation(): + # we had a cyclic import there + # requires pytest on sys.path + res = py.std.subprocess.call([ + py.std.sys.executable, '-c', str(py.code.Source(""" + try: + from _pytest.assertion.newinterpret import interpret + except ImportError: + from _pytest.assertion.oldinterpret import interpret + """)) + ]) + + assert res == 0