diff options
author | Ran Benita <ran@unusedvar.com> | 2020-06-20 15:59:29 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-06-21 19:54:29 +0300 |
commit | c9737ae914891027da5f0bd39494dd51a3b3f19f (patch) | |
tree | c6bb7ad3ab59fb4b48561345a1900bb9fb9987c8 /src/_pytest/skipping.py | |
parent | 3e6fe92b7ea3c120e8024a970bf37a7c6c137714 (diff) | |
download | pytest-c9737ae914891027da5f0bd39494dd51a3b3f19f.tar.gz |
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.
Diffstat (limited to 'src/_pytest/skipping.py')
-rw-r--r-- | src/_pytest/skipping.py | 21 |
1 files changed, 7 insertions, 14 deletions
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) |