fixtures: show test as skip location if skipped from an xunit setup function
Fix #11216.
This commit is contained in:
+11
-10
@@ -989,33 +989,34 @@ def test_skipped_reasons_functional(pytester: Pytester) -> None:
|
||||
pytester.makepyfile(
|
||||
test_one="""
|
||||
import pytest
|
||||
from conftest import doskip
|
||||
from helpers import doskip
|
||||
|
||||
def setup_function(func):
|
||||
doskip()
|
||||
def setup_function(func): # LINE 4
|
||||
doskip("setup function")
|
||||
|
||||
def test_func():
|
||||
pass
|
||||
|
||||
class TestClass(object):
|
||||
class TestClass:
|
||||
def test_method(self):
|
||||
doskip()
|
||||
doskip("test method")
|
||||
|
||||
@pytest.mark.skip("via_decorator")
|
||||
@pytest.mark.skip("via_decorator") # LINE 14
|
||||
def test_deco(self):
|
||||
assert 0
|
||||
""",
|
||||
conftest="""
|
||||
helpers="""
|
||||
import pytest, sys
|
||||
def doskip():
|
||||
def doskip(reason):
|
||||
assert sys._getframe().f_lineno == 3
|
||||
pytest.skip('test')
|
||||
pytest.skip(reason) # LINE 4
|
||||
""",
|
||||
)
|
||||
result = pytester.runpytest("-rs")
|
||||
result.stdout.fnmatch_lines_random(
|
||||
[
|
||||
"SKIPPED [[]2[]] conftest.py:4: test",
|
||||
"SKIPPED [[]1[]] test_one.py:7: setup function",
|
||||
"SKIPPED [[]1[]] helpers.py:4: test method",
|
||||
"SKIPPED [[]1[]] test_one.py:14: via_decorator",
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user