File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1+ Add '.exception' attribute as an alias for '.value' to facilitate porting tests written using unittest.
Original file line number Diff line number Diff line change @@ -422,6 +422,20 @@ def type(self):
422422 def value (self ):
423423 """the exception value"""
424424 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
425439
426440 @property
427441 def tb (self ):
You can’t perform that action at this time.
0 commit comments