make py.test.raises as-VAR be an ExceptionInfo object

but only initialize it after the block is finished.

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-06-09 14:45:41 +02:00
parent 6951da7da0
commit 523704f890
4 changed files with 23 additions and 9 deletions

View File

@@ -347,12 +347,11 @@ class TestRaises:
import py
def test_simple():
with py.test.raises(ZeroDivisionError) as ctx:
with py.test.raises(ZeroDivisionError) as excinfo:
assert isinstance(excinfo, py.code.ExceptionInfo)
1/0
print ctx.excinfo
assert ctx.excinfo.type is ZeroDivisionError
print (excinfo)
assert excinfo.type == ZeroDivisionError
def test_noraise():
with py.test.raises(py.test.raises.Exception):