File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed
Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 1+ Removes unhelpful error message from assertion rewrite mechanism when exceptions raised in __iter__ methods, and instead treats them as un-iterable.
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ def isiterable(obj: Any) -> bool:
132132 try :
133133 iter (obj )
134134 return not istext (obj )
135- except TypeError :
135+ except Exception :
136136 return False
137137
138138
Original file line number Diff line number Diff line change @@ -689,16 +689,19 @@ def test_assert_handling_raise_in__iter__(self) -> None:
689689 def f () -> None :
690690 class A :
691691 def __iter__ (self ):
692- raise TypeError ( "user message" )
692+ raise ValueError ( )
693693
694694 def __eq__ (self , o : object ) -> bool :
695695 return self is o
696696
697+ def __repr__ (self ):
698+ return "<A object>"
699+
697700 assert A () == A ()
698701
699702 msg = getmsg (f )
700703 assert msg is not None
701- assert "Unexpected exception " in msg
704+ assert "<A object> == <A object> " in msg
702705
703706 def test_formatchar (self ) -> None :
704707 def f () -> None :
You can’t perform that action at this time.
0 commit comments