File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 1+ If a test is skipped from inside an :ref: `xunit setup fixture <classic xunit >`, the test summary now shows the test location instead of the fixture location.
Original file line number Diff line number Diff line change @@ -1162,9 +1162,10 @@ def pytest_fixture_setup(
11621162 try :
11631163 result = call_fixture_func (fixturefunc , request , kwargs )
11641164 except TEST_OUTCOME as e :
1165- if isinstance (e , skip .Exception ) and not fixturefunc .__name__ .startswith (
1166- "xunit_setup"
1167- ):
1165+ if isinstance (e , skip .Exception ):
1166+ # The test requested a fixture which caused a skip.
1167+ # Don't show the fixture as the skip location, as then the user
1168+ # wouldn't know which test skipped.
11681169 e ._use_item_location = True
11691170 fixturedef .cached_result = (None , my_cache_key , e )
11701171 raise
Original file line number Diff line number Diff line change @@ -989,33 +989,34 @@ def test_skipped_reasons_functional(pytester: Pytester) -> None:
989989 pytester .makepyfile (
990990 test_one = """
991991 import pytest
992- from conftest import doskip
992+ from helpers import doskip
993993
994- def setup_function(func):
995- doskip()
994+ def setup_function(func): # LINE 4
995+ doskip("setup function" )
996996
997997 def test_func():
998998 pass
999999
1000- class TestClass(object) :
1000+ class TestClass:
10011001 def test_method(self):
1002- doskip()
1002+ doskip("test method" )
10031003
1004- @pytest.mark.skip("via_decorator")
1004+ @pytest.mark.skip("via_decorator") # LINE 14
10051005 def test_deco(self):
10061006 assert 0
10071007 """ ,
1008- conftest = """
1008+ helpers = """
10091009 import pytest, sys
1010- def doskip():
1010+ def doskip(reason ):
10111011 assert sys._getframe().f_lineno == 3
1012- pytest.skip('test')
1012+ pytest.skip(reason) # LINE 4
10131013 """ ,
10141014 )
10151015 result = pytester .runpytest ("-rs" )
10161016 result .stdout .fnmatch_lines_random (
10171017 [
1018- "SKIPPED [[]2[]] conftest.py:4: test" ,
1018+ "SKIPPED [[]1[]] test_one.py:7: setup function" ,
1019+ "SKIPPED [[]1[]] helpers.py:4: test method" ,
10191020 "SKIPPED [[]1[]] test_one.py:14: via_decorator" ,
10201021 ]
10211022 )
You can’t perform that action at this time.
0 commit comments