improve error msg and test
This commit is contained in:
parent
ec1053cc16
commit
c0cf822ca1
|
@ -136,7 +136,10 @@ def isiterable(obj: Any) -> bool:
|
|||
return False
|
||||
except Exception as e:
|
||||
raise ValueError(
|
||||
f"Unexpected exception {e!r} while testing object {obj!r}. Probably an issue with __iter__"
|
||||
[
|
||||
f"pytest_assertion plugin: unexpected exception {e!r} while testing object {obj!r}",
|
||||
", probably from __iter__",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
@ -203,9 +206,9 @@ def assertrepr_compare(
|
|||
if (
|
||||
isinstance(e, ValueError)
|
||||
and (len(e.args) == 1)
|
||||
and ("Unexpected exception" in str(e.args[0]))
|
||||
and ("__iter__" in str(e.args[0]))
|
||||
):
|
||||
explanation = [e.args[0]]
|
||||
explanation = e.args[0]
|
||||
else:
|
||||
explanation = [
|
||||
"(pytest_assertion plugin: representation of details failed: {}.".format(
|
||||
|
|
|
@ -698,7 +698,7 @@ class TestAssertionRewrite:
|
|||
|
||||
msg = getmsg(f)
|
||||
assert msg is not None
|
||||
assert "Unexpected exception" in msg
|
||||
assert "__iter__" in msg and "__repr__" not in msg
|
||||
|
||||
def test_formatchar(self) -> None:
|
||||
def f() -> None:
|
||||
|
|
Loading…
Reference in New Issue