skipping: replace _evalskip with a more consistent _skipped_by_mark
This commit is contained in:
parent
a33650953a
commit
9ad2b75038
|
@ -155,17 +155,17 @@ class MarkEvaluator:
|
||||||
@hookimpl(tryfirst=True)
|
@hookimpl(tryfirst=True)
|
||||||
def pytest_runtest_setup(item):
|
def pytest_runtest_setup(item):
|
||||||
# Check if skip or skipif are specified as pytest marks
|
# Check if skip or skipif are specified as pytest marks
|
||||||
|
item._skipped_by_mark = False
|
||||||
skipif_info = item.keywords.get('skipif')
|
skipif_info = item.keywords.get('skipif')
|
||||||
if isinstance(skipif_info, (MarkInfo, MarkDecorator)):
|
if isinstance(skipif_info, (MarkInfo, MarkDecorator)):
|
||||||
eval_skipif = MarkEvaluator(item, 'skipif')
|
eval_skipif = MarkEvaluator(item, 'skipif')
|
||||||
if eval_skipif.istrue():
|
if eval_skipif.istrue():
|
||||||
item._evalskip = eval_skipif
|
item._skipped_by_mark = True
|
||||||
skip(eval_skipif.getexplanation())
|
skip(eval_skipif.getexplanation())
|
||||||
|
|
||||||
skip_info = item.keywords.get('skip')
|
skip_info = item.keywords.get('skip')
|
||||||
if isinstance(skip_info, (MarkInfo, MarkDecorator)):
|
if isinstance(skip_info, (MarkInfo, MarkDecorator)):
|
||||||
item._evalskip = True
|
item._skipped_by_mark = True
|
||||||
if 'reason' in skip_info.kwargs:
|
if 'reason' in skip_info.kwargs:
|
||||||
skip(skip_info.kwargs['reason'])
|
skip(skip_info.kwargs['reason'])
|
||||||
elif skip_info.args:
|
elif skip_info.args:
|
||||||
|
@ -212,7 +212,6 @@ def pytest_runtest_makereport(item, call):
|
||||||
outcome = yield
|
outcome = yield
|
||||||
rep = outcome.get_result()
|
rep = outcome.get_result()
|
||||||
evalxfail = getattr(item, '_evalxfail', None)
|
evalxfail = getattr(item, '_evalxfail', None)
|
||||||
evalskip = getattr(item, '_evalskip', None)
|
|
||||||
# unitttest special case, see setting of _unexpectedsuccess
|
# unitttest special case, see setting of _unexpectedsuccess
|
||||||
if hasattr(item, '_unexpectedsuccess') and rep.when == "call":
|
if hasattr(item, '_unexpectedsuccess') and rep.when == "call":
|
||||||
from _pytest.compat import _is_unittest_unexpected_success_a_failure
|
from _pytest.compat import _is_unittest_unexpected_success_a_failure
|
||||||
|
@ -248,7 +247,7 @@ def pytest_runtest_makereport(item, call):
|
||||||
else:
|
else:
|
||||||
rep.outcome = "passed"
|
rep.outcome = "passed"
|
||||||
rep.wasxfail = explanation
|
rep.wasxfail = explanation
|
||||||
elif evalskip is not None and rep.skipped and type(rep.longrepr) is tuple:
|
elif item._skipped_by_mark and rep.skipped and type(rep.longrepr) is tuple:
|
||||||
# skipped by mark.skipif; change the location of the failure
|
# skipped by mark.skipif; change the location of the failure
|
||||||
# to point to the item definition, otherwise it will display
|
# to point to the item definition, otherwise it will display
|
||||||
# the location of where the skip exception was raised within pytest
|
# the location of where the skip exception was raised within pytest
|
||||||
|
|
|
@ -133,7 +133,7 @@ class TestCaseFunction(Function):
|
||||||
try:
|
try:
|
||||||
skip(reason)
|
skip(reason)
|
||||||
except skip.Exception:
|
except skip.Exception:
|
||||||
self._evalskip = True
|
self._skipped_by_mark = True
|
||||||
self._addexcinfo(sys.exc_info())
|
self._addexcinfo(sys.exc_info())
|
||||||
|
|
||||||
def addExpectedFailure(self, testcase, rawexcinfo, reason=""):
|
def addExpectedFailure(self, testcase, rawexcinfo, reason=""):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
* remove the internal optional multi-typed attribute _evalskip
|
||||||
|
and replacce it with the boolean _skipped_by_mark
|
Loading…
Reference in New Issue