From 5171d167ce8e3bb5fe69544a204ac0edeeee58a7 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 2 Oct 2015 17:55:28 -0300 Subject: [PATCH] Move "note" to the end of the main text Fix #1097 --- _pytest/python.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index b04297b95..311ed6ec7 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1194,6 +1194,25 @@ def raises(expected_exception, *args, **kwargs): >>> with raises(ZeroDivisionError): ... 1/0 + Or you can specify a callable by passing a to-be-called lambda:: + + >>> raises(ZeroDivisionError, lambda: 1/0) + + + or you can specify an arbitrary callable with arguments:: + + >>> def f(x): return 1/x + ... + >>> raises(ZeroDivisionError, f, 0) + + >>> raises(ZeroDivisionError, f, x=0) + + + A third possibility is to use a string to be executed:: + + >>> raises(ZeroDivisionError, "f(0)") + + .. note:: When using ``pytest.raises`` as a context manager, it's worthwhile to @@ -1216,25 +1235,6 @@ def raises(expected_exception, *args, **kwargs): assert err.errno = errno.EEXISTS # this will now execute - Or you can specify a callable by passing a to-be-called lambda:: - - >>> raises(ZeroDivisionError, lambda: 1/0) - - - or you can specify an arbitrary callable with arguments:: - - >>> def f(x): return 1/x - ... - >>> raises(ZeroDivisionError, f, 0) - - >>> raises(ZeroDivisionError, f, x=0) - - - A third possibility is to use a string to be executed:: - - >>> raises(ZeroDivisionError, "f(0)") - - Performance note: -----------------