1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/commits/bbc15902ae03/
Changeset: bbc15902ae03
User: flub
Date: 2014-09-08 15:26:31
Summary: Improve pytest.raises examples
Fixes issue #586.
Affected #: 1 file
diff -r c07682cb75ebe46ad79de86b9689cefb4b69f78d -r
bbc15902ae03b5efe0b0afdfb37cd1796426ba0a doc/en/assert.txt
--- a/doc/en/assert.txt
+++ b/doc/en/assert.txt
@@ -66,20 +66,23 @@
``pytest.raises`` as a context manager like this::
import pytest
- with pytest.raises(ZeroDivisionError):
- 1 / 0
+
+ def test_zero_division():
+ with pytest.raises(ZeroDivisionError):
+ 1 / 0
and if you need to have access to the actual exception info you may use::
- with pytest.raises(RuntimeError) as excinfo:
- def f():
+ def test_recursion_depth():
+ with pytest.raises(RuntimeError) as excinfo:
+ def f():
+ f()
f()
- f()
-
- # do checks related to excinfo.type, excinfo.value, excinfo.traceback
+ assert 'maximum recursion' in str(excinfo.value)
``excinfo`` is a `py.code.ExceptionInfo`_ instance, which is a wrapper around
-the actual exception raised.
+the actual exception raised. The main attributes of interest are
+``.type``, ``.value`` and ``.traceback``.
.. _py.code.ExceptionInfo:
http://pylib.readthedocs.org/en/latest/code.html#py-code-exceptioninfo
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
pytest-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit