File tree Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -704,10 +704,11 @@ def __exit__(
704704 if exc_type is None :
705705 if not self .expected_exceptions :
706706 fail ("DID NOT RAISE any exception" )
707- if len (self .expected_exceptions ) > 1 :
708- fail (f"DID NOT RAISE any of { self .expected_exceptions !r} " )
709-
710- fail (f"DID NOT RAISE { self .expected_exceptions [0 ]!r} " )
707+ if len (self .expected_exceptions ) == 1 :
708+ fail (f"DID NOT RAISE { self .expected_exceptions [0 ].__name__ !r} " )
709+ else :
710+ names = ", " .join (f"{ x .__name__ !r} " for x in self .expected_exceptions )
711+ fail (f"DID NOT RAISE any of ({ names } )" )
711712
712713 assert self .excinfo is not None , (
713714 "Internal error - should have been constructed in __enter__"
Original file line number Diff line number Diff line change @@ -194,15 +194,15 @@ def test_no_raise_message(self) -> None:
194194 try :
195195 pytest .raises (ValueError , int , "0" )
196196 except pytest .fail .Exception as e :
197- assert e .msg == f"DID NOT RAISE { ValueError !r } "
197+ assert e .msg == f"DID NOT RAISE ' ValueError' "
198198 else :
199199 assert False , "Expected pytest.raises.Exception"
200200
201201 try :
202202 with pytest .raises (ValueError ):
203203 pass
204204 except pytest .fail .Exception as e :
205- assert e .msg == f"DID NOT RAISE { ValueError !r } "
205+ assert e .msg == f"DID NOT RAISE ' ValueError' "
206206 else :
207207 assert False , "Expected pytest.raises.Exception"
208208
@@ -333,7 +333,7 @@ class ClassLooksIterableException(Exception, metaclass=Meta):
333333
334334 with pytest .raises (
335335 Failed ,
336- match = r"DID NOT RAISE <class 'raises(\..*)* ClassLooksIterableException'> " ,
336+ match = r"DID NOT RAISE ' ClassLooksIterableException'" ,
337337 ):
338338 pytest .raises (ClassLooksIterableException , lambda : None )
339339
Original file line number Diff line number Diff line change @@ -1099,7 +1099,7 @@ def test_raisesexc() -> None:
10991099
11001100 # FIXME: leaving this one formatted differently for now to not change
11011101 # tests in python/raises.py
1102- with pytest .raises (Failed , match = wrap_escape ("DID NOT RAISE <class 'ValueError'> " )):
1102+ with pytest .raises (Failed , match = wrap_escape ("DID NOT RAISE 'ValueError'" )):
11031103 with RaisesExc (ValueError ):
11041104 ...
11051105
@@ -1111,7 +1111,7 @@ def test_raisesexc() -> None:
11111111 # FIXME: do we want repr(type) or type.__name__ ?
11121112 Failed ,
11131113 match = wrap_escape (
1114- "DID NOT RAISE any of (<class 'ValueError'>, <class 'TypeError'> )"
1114+ "DID NOT RAISE any of ('ValueError', 'TypeError')"
11151115 ),
11161116 ):
11171117 with RaisesExc ((ValueError , TypeError )):
You can’t perform that action at this time.
0 commit comments