summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-06-24 12:06:53 -0700
committerGitHub <noreply@github.com>2019-06-24 12:06:53 -0700
commita24933b0a6ad32e5d71a535ca8c7900551a22dfc (patch)
tree93d506577c39b19d250550669e757af86e8719a8 /src
parent61dcb84f0dd71d8a46c5b1db3bbe563bd731adb3 (diff)
parent380ca8f8805ee6bbdbb7c9de8a3c136c2614bab1 (diff)
downloadpytest-a24933b0a6ad32e5d71a535ca8c7900551a22dfc.tar.gz
Merge pull request #5481 from asottile/minor_py3_cleanup
Use new raise syntax in one case
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/outcomes.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py
index 749e80f3c..fb4d471b5 100644
--- a/src/_pytest/outcomes.py
+++ b/src/_pytest/outcomes.py
@@ -149,7 +149,6 @@ def importorskip(modname, minversion=None, reason=None):
__tracebackhide__ = True
compile(modname, "", "eval") # to catch syntaxerrors
- import_exc = None
with warnings.catch_warnings():
# make sure to ignore ImportWarnings that might happen because
@@ -159,12 +158,9 @@ def importorskip(modname, minversion=None, reason=None):
try:
__import__(modname)
except ImportError as exc:
- # Do not raise chained exception here(#1485)
- import_exc = exc
- if import_exc:
- if reason is None:
- reason = "could not import {!r}: {}".format(modname, import_exc)
- raise Skipped(reason, allow_module_level=True)
+ if reason is None:
+ reason = "could not import {!r}: {}".format(modname, exc)
+ raise Skipped(reason, allow_module_level=True) from None
mod = sys.modules[modname]
if minversion is None:
return mod