File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -132,8 +132,14 @@ def isiterable(obj: Any) -> bool:
132132 try :
133133 iter (obj )
134134 return not istext (obj )
135- except TypeError :
136- return False
135+ except Exception as e :
136+ if (
137+ isinstance (e , TypeError )
138+ and (len (e .args ) == 1 )
139+ and "iter() returned non-iterator of type" in str (e .args [0 ])
140+ ):
141+ return False
142+ raise ValueError (f"Unexpected exception { e !r} while testing object { obj !r} " )
137143
138144
139145def has_default_eq (
@@ -195,13 +201,20 @@ def assertrepr_compare(
195201 explanation = _notin_text (left , right , verbose )
196202 except outcomes .Exit :
197203 raise
198- except Exception :
199- explanation = [
200- "(pytest_assertion plugin: representation of details failed: {}." .format (
201- _pytest ._code .ExceptionInfo .from_current ()._getreprcrash ()
202- ),
203- " Probably an object has a faulty __repr__.)" ,
204- ]
204+ except Exception as e :
205+ if (
206+ isinstance (e , ValueError )
207+ and (len (e .args ) == 1 )
208+ and ("Unexpected exception" in str (e .args [0 ]))
209+ ):
210+ explanation = [e .args [0 ]]
211+ else :
212+ explanation = [
213+ "(pytest_assertion plugin: representation of details failed: {}." .format (
214+ _pytest ._code .ExceptionInfo .from_current ()._getreprcrash ()
215+ ),
216+ " Probably an object has a faulty __repr__.)" ,
217+ ]
205218
206219 if not explanation :
207220 return None
You can’t perform that action at this time.
0 commit comments