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 1ebc8f9Copy full SHA for 1ebc8f9
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,20 @@ def type(self):
422
def value(self):
423
"""the exception value"""
424
return self._excinfo[1]
425
+
426
+ @property
427
+ def exception(self):
428
+ """
429
+ an alias to '.value' to facilitate porting porting tests written using
430
+ unittest. Prefer '.value' in new code.
431
432
+ msg = (
433
+ "The '.exception' attribute is an alias to facilitate porting "
434
+ "tests written using unittest.\n"
435
+ "Prefer '.value' in new code."
436
+ )
437
+ warnings.warn(PytestWarning(msg), stacklevel=2)
438
+ return self.value
439
440
@property
441
def tb(self):
0 commit comments