File tree Expand file tree Collapse file tree 3 files changed +5
-18
lines changed Expand file tree Collapse file tree 3 files changed +5
-18
lines changed Original file line number Diff line number Diff line change
1
+ ``ExceptionInfo `` objects (returned by ``pytest.raises ``) now have the same ``str `` representation as ``repr ``, which
2
+ avoids some confusion when users use ``print(e) `` to inspect the object.
Original file line number Diff line number Diff line change @@ -534,13 +534,6 @@ def getrepr(
534
534
)
535
535
return fmt .repr_excinfo (self )
536
536
537
- def __str__ (self ):
538
- if self ._excinfo is None :
539
- return repr (self )
540
- entry = self .traceback [- 1 ]
541
- loc = ReprFileLocation (entry .path , entry .lineno + 1 , self .exconly ())
542
- return str (loc )
543
-
544
537
def match (self , regexp ):
545
538
"""
546
539
Check whether the regular expression 'regexp' is found in the string
Original file line number Diff line number Diff line change @@ -333,18 +333,10 @@ def test_excinfo_exconly():
333
333
assert msg .endswith ("world" )
334
334
335
335
336
- def test_excinfo_repr ():
336
+ def test_excinfo_repr_str ():
337
337
excinfo = pytest .raises (ValueError , h )
338
- s = repr (excinfo )
339
- assert s == "<ExceptionInfo ValueError tblen=4>"
340
-
341
-
342
- def test_excinfo_str ():
343
- excinfo = pytest .raises (ValueError , h )
344
- s = str (excinfo )
345
- assert s .startswith (__file__ [:- 9 ]) # pyc file and $py.class
346
- assert s .endswith ("ValueError" )
347
- assert len (s .split (":" )) >= 3 # on windows it's 4
338
+ assert repr (excinfo ) == "<ExceptionInfo ValueError tblen=4>"
339
+ assert str (excinfo ) == "<ExceptionInfo ValueError tblen=4>"
348
340
349
341
350
342
def test_excinfo_for_later ():
You can’t perform that action at this time.
0 commit comments