summaryrefslogtreecommitdiff
path: root/src/_pytest/python_api.py
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2020-05-12 12:07:56 +0300
committerRan Benita <ran@unusedvar.com>2020-05-12 12:07:56 +0300
commit645aaa728d515558725eb4d9bf8414612dfe4513 (patch)
tree8948c03daf8477f2f0ece582583ee8be7b81016a /src/_pytest/python_api.py
parent23c9856857b4fad351491b064a30a1e1eddc0589 (diff)
downloadpytest-645aaa728d515558725eb4d9bf8414612dfe4513.tar.gz
python_api: reduce scope of a `except BaseException` in ApproxNumpy
I'm not sure if it can even raise at all, but catching BaseException would swallow ctrl-C and such and is definitely inappropriate here.
Diffstat (limited to 'src/_pytest/python_api.py')
-rw-r--r--src/_pytest/python_api.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py
index a523caae5..29c8af7e2 100644
--- a/src/_pytest/python_api.py
+++ b/src/_pytest/python_api.py
@@ -123,8 +123,10 @@ class ApproxNumpy(ApproxBase):
if not np.isscalar(actual):
try:
actual = np.asarray(actual)
- except BaseException:
- raise TypeError("cannot compare '{}' to numpy.ndarray".format(actual))
+ except Exception as e:
+ raise TypeError(
+ "cannot compare '{}' to numpy.ndarray".format(actual)
+ ) from e
if not np.isscalar(actual) and actual.shape != self.expected.shape:
return False