File tree 3 files changed +12
-0
lines changed 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 1
1
2.7.2 (compared to 2.7.1)
2
2
-----------------------------
3
3
4
+ - fix issue767: pytest.raises value attribute does not contain the exception
5
+ instance on Python 2.6. Thanks Eric Siegerman for providing the test
6
+ case and Bruno Oliveira for PR.
7
+
4
8
- Automatically create directory for junitxml and results log.
5
9
Thanks Aron Curzon.
6
10
Original file line number Diff line number Diff line change @@ -1099,6 +1099,13 @@ def __exit__(self, *tp):
1099
1099
__tracebackhide__ = True
1100
1100
if tp [0 ] is None :
1101
1101
pytest .fail ("DID NOT RAISE" )
1102
+ if sys .version_info < (2 , 7 ):
1103
+ # py26: on __exit__() exc_value often does not contain the
1104
+ # exception value.
1105
+ # http://bugs.python.org/issue7853
1106
+ if not isinstance (tp [1 ], BaseException ):
1107
+ exc_type , value , traceback = tp
1108
+ tp = exc_type , exc_type (value ), traceback
1102
1109
self .excinfo .__init__ (tp )
1103
1110
return issubclass (self .excinfo .type , self .ExpectedException )
1104
1111
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ def test_simple():
46
46
1/0
47
47
print (excinfo)
48
48
assert excinfo.type == ZeroDivisionError
49
+ assert isinstance(excinfo.value, ZeroDivisionError)
49
50
50
51
def test_noraise():
51
52
with pytest.raises(pytest.raises.Exception):
You can’t perform that action at this time.
0 commit comments