Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new raise syntax in one case #5481

Merged
merged 1 commit into from Jun 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/_pytest/outcomes.py
Expand Up @@ -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
Expand All @@ -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
Expand Down