Improve error message for invalid types passed to pytest.approx()
* Hide the internal traceback * Use !r representation instead of !s (the default for {} formatting)
This commit is contained in:
parent
327fe4cfcc
commit
bf7c188cc0
|
@ -34,7 +34,7 @@ def _cmp_raises_type_error(self, other):
|
||||||
|
|
||||||
def _non_numeric_type_error(value):
|
def _non_numeric_type_error(value):
|
||||||
return TypeError(
|
return TypeError(
|
||||||
"cannot make approximate comparisons to non-numeric values, e.g. {}".format(
|
"cannot make approximate comparisons to non-numeric values, e.g. {!r}".format(
|
||||||
value
|
value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -507,6 +507,8 @@ def approx(expected, rel=None, abs=None, nan_ok=False):
|
||||||
# class provides some convenient methods and overloads, but isn't really
|
# class provides some convenient methods and overloads, but isn't really
|
||||||
# essential.
|
# essential.
|
||||||
|
|
||||||
|
__tracebackhide__ = True
|
||||||
|
|
||||||
if isinstance(expected, Decimal):
|
if isinstance(expected, Decimal):
|
||||||
cls = ApproxDecimal
|
cls = ApproxDecimal
|
||||||
elif isinstance(expected, Number):
|
elif isinstance(expected, Number):
|
||||||
|
|
Loading…
Reference in New Issue