From 43aee15ba31f32781c3e91333db3e4dd65aaaab3 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 15 Mar 2019 10:16:11 +0900 Subject: [PATCH] Make pytest.skip work in doctest --- src/_pytest/doctest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index d34cb638c..34b6c9d8c 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -15,6 +15,7 @@ from _pytest._code.code import ReprFileLocation from _pytest._code.code import TerminalRepr from _pytest.compat import safe_getattr from _pytest.fixtures import FixtureRequest +from _pytest.outcomes import Skipped DOCTEST_REPORT_CHOICE_NONE = "none" DOCTEST_REPORT_CHOICE_CDIFF = "cdiff" @@ -153,6 +154,8 @@ def _init_runner_class(): raise failure def report_unexpected_exception(self, out, test, example, exc_info): + if isinstance(exc_info[1], Skipped): + raise exc_info[1] failure = doctest.UnexpectedException(test, example, exc_info) if self.continue_on_failure: out.append(failure)