diff --git a/_pytest/python.py b/_pytest/python.py index e763aa888..61000676e 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -22,6 +22,7 @@ from _pytest.compat import ( get_real_func, getfslineno, safe_getattr, getlocation, enum, ) +from _pytest.runner import fail cutdir1 = py.path.local(pluggy.__file__.rstrip("oc")) cutdir2 = py.path.local(_pytest.__file__).dirpath() @@ -126,21 +127,6 @@ def pytest_configure(config): "all of the specified fixtures. see http://pytest.org/latest/fixture.html#usefixtures " ) -@pytest.hookimpl(trylast=True) -def pytest_namespace(): - raises.Exception = pytest.fail.Exception - return { - 'raises': raises, - 'approx': approx, - 'collect': { - 'Module': Module, - 'Class': Class, - 'Instance': Instance, - 'Function': Function, - 'Generator': Generator, - } - } - @pytest.hookimpl(trylast=True) def pytest_pyfunc_call(pyfuncitem): @@ -1234,7 +1220,11 @@ def raises(expected_exception, *args, **kwargs): func(*args[1:], **kwargs) except expected_exception: return _pytest._code.ExceptionInfo() - pytest.fail(message) + fail(message) + +raises.Exception = fail.Exception + + class RaisesContext(object): def __init__(self, expected_exception, message, match_expr): diff --git a/pytest.py b/pytest.py index a072b49ae..8185d6503 100644 --- a/pytest.py +++ b/pytest.py @@ -55,6 +55,10 @@ from _pytest.mark import MARK_GEN as mark from _pytest.skipping import xfail from _pytest.main import Item, Collector, File, Session from _pytest.fixtures import fillfixtures as _fillfuncargs +from _pytest.python import ( + raises, approx, + Module, Class, Instance, Function, Generator, +) set_trace = __pytestPDB.set_trace