From c9737ae914891027da5f0bd39494dd51a3b3f19f Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 20 Jun 2020 15:59:29 +0300 Subject: skipping: simplify xfail handling during call phase There is no need to do the XPASS check here, pytest_runtest_makereport already handled that (the current handling there is dead code). All the hook needs to do is refresh the xfail evaluation if needed, and check the NOTRUN condition again. --- src/_pytest/skipping.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/_pytest/skipping.py') diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 894eda499..7fc43fce1 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -3,6 +3,7 @@ import os import platform import sys import traceback +from typing import Generator from typing import Optional from typing import Tuple @@ -244,24 +245,16 @@ def pytest_runtest_setup(item: Item) -> None: @hookimpl(hookwrapper=True) -def pytest_runtest_call(item: Item): +def pytest_runtest_call(item: Item) -> Generator[None, None, None]: + xfailed = item._store.get(xfailed_key, None) + if xfailed is None: + item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item) + if not item.config.option.runxfail: - xfailed = item._store.get(xfailed_key, None) - if xfailed is None: - item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item) if xfailed and not xfailed.run: xfail("[NOTRUN] " + xfailed.reason) - outcome = yield - passed = outcome.excinfo is None - - if passed: - xfailed = item._store.get(xfailed_key, None) - if xfailed is None: - item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item) - if xfailed and xfailed.strict: - del item._store[xfailed_key] - fail("[XPASS(strict)] " + xfailed.reason, pytrace=False) + yield @hookimpl(hookwrapper=True) -- cgit v1.2.3