Revert iter raises checks
This reverts commite938580257
. Revert "improve error msg and test" This reverts commitc0cf822ca1
. Revert "error msg" This reverts commitec1053cc16
. Revert "changelog" This reverts commitd2dc8a70b5
. Revert "simplify code / take out user-gen typeerror case" This reverts commitb9cb87d862
.
This commit is contained in:
parent
c0cf822ca1
commit
049eec8474
|
@ -1 +0,0 @@
|
||||||
Assertion rewrite mechanism now gives a seperate, more detailed error message from failures within __iter__.
|
|
|
@ -134,13 +134,6 @@ def isiterable(obj: Any) -> bool:
|
||||||
return not istext(obj)
|
return not istext(obj)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
|
||||||
raise ValueError(
|
|
||||||
[
|
|
||||||
f"pytest_assertion plugin: unexpected exception {e!r} while testing object {obj!r}",
|
|
||||||
", probably from __iter__",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def has_default_eq(
|
def has_default_eq(
|
||||||
|
@ -202,14 +195,7 @@ def assertrepr_compare(
|
||||||
explanation = _notin_text(left, right, verbose)
|
explanation = _notin_text(left, right, verbose)
|
||||||
except outcomes.Exit:
|
except outcomes.Exit:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception:
|
||||||
if (
|
|
||||||
isinstance(e, ValueError)
|
|
||||||
and (len(e.args) == 1)
|
|
||||||
and ("__iter__" in str(e.args[0]))
|
|
||||||
):
|
|
||||||
explanation = e.args[0]
|
|
||||||
else:
|
|
||||||
explanation = [
|
explanation = [
|
||||||
"(pytest_assertion plugin: representation of details failed: {}.".format(
|
"(pytest_assertion plugin: representation of details failed: {}.".format(
|
||||||
_pytest._code.ExceptionInfo.from_current()._getreprcrash()
|
_pytest._code.ExceptionInfo.from_current()._getreprcrash()
|
||||||
|
|
|
@ -689,7 +689,7 @@ class TestAssertionRewrite:
|
||||||
def f() -> None:
|
def f() -> None:
|
||||||
class A:
|
class A:
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
raise ValueError()
|
raise TypeError("user message")
|
||||||
|
|
||||||
def __eq__(self, o: object) -> bool:
|
def __eq__(self, o: object) -> bool:
|
||||||
return self is o
|
return self is o
|
||||||
|
@ -698,7 +698,7 @@ class TestAssertionRewrite:
|
||||||
|
|
||||||
msg = getmsg(f)
|
msg = getmsg(f)
|
||||||
assert msg is not None
|
assert msg is not None
|
||||||
assert "__iter__" in msg and "__repr__" not in msg
|
assert "Unexpected exception" in msg
|
||||||
|
|
||||||
def test_formatchar(self) -> None:
|
def test_formatchar(self) -> None:
|
||||||
def f() -> None:
|
def f() -> None:
|
||||||
|
|
Loading…
Reference in New Issue