We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4f9bf02 commit 127de96Copy full SHA for 127de96
changelog/5541.feature.rst
@@ -0,0 +1 @@
1
+Add '.exception' attribute as an alias for '.value' to facilitate porting tests written using unittest.
src/_pytest/_code/code.py
@@ -422,6 +422,16 @@ def type(self):
422
def value(self):
423
"""the exception value"""
424
return self._excinfo[1]
425
+
426
+ @property
427
+ def exception(self):
428
+ msg = (
429
+ "The '.exception' attribute is an alias to facilitate porting "
430
+ "tests written using unittest.\n"
431
+ "Prefer '.value' in new code."
432
+ )
433
+ warnings.warn(PytestWarning(msg), stacklevel=2)
434
+ return self.value
435
436
@property
437
def tb(self):
0 commit comments