check for user-generated exceptions
This commit is contained in:
parent
47c0fc3d78
commit
e938580257
|
@ -132,8 +132,14 @@ def isiterable(obj: Any) -> bool:
|
||||||
try:
|
try:
|
||||||
iter(obj)
|
iter(obj)
|
||||||
return not istext(obj)
|
return not istext(obj)
|
||||||
except TypeError:
|
except Exception as e:
|
||||||
|
if (
|
||||||
|
isinstance(e, TypeError)
|
||||||
|
and (len(e.args) == 1)
|
||||||
|
and "iter() returned non-iterator of type" in str(e.args[0])
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
|
raise ValueError(f"Unexpected exception {e!r} while testing object {obj!r}")
|
||||||
|
|
||||||
|
|
||||||
def has_default_eq(
|
def has_default_eq(
|
||||||
|
@ -195,7 +201,14 @@ 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:
|
except Exception as e:
|
||||||
|
if (
|
||||||
|
isinstance(e, ValueError)
|
||||||
|
and (len(e.args) == 1)
|
||||||
|
and ("Unexpected exception" 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()
|
||||||
|
|
Loading…
Reference in New Issue