parent
bc4e70e048
commit
791b51d0fa
1
AUTHORS
1
AUTHORS
|
@ -90,6 +90,7 @@ Daniel Grana
|
||||||
Daniel Hahler
|
Daniel Hahler
|
||||||
Daniel Nuri
|
Daniel Nuri
|
||||||
Daniel Sánchez Castelló
|
Daniel Sánchez Castelló
|
||||||
|
Daniel Valenzuela Zenteno
|
||||||
Daniel Wandschneider
|
Daniel Wandschneider
|
||||||
Daniele Procida
|
Daniele Procida
|
||||||
Danielle Jenkins
|
Danielle Jenkins
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
If a test is skipped from inside a fixture, the test summary now shows the test location instead of the fixture location.
|
|
@ -58,6 +58,7 @@ from _pytest.mark import Mark
|
||||||
from _pytest.mark import ParameterSet
|
from _pytest.mark import ParameterSet
|
||||||
from _pytest.mark.structures import MarkDecorator
|
from _pytest.mark.structures import MarkDecorator
|
||||||
from _pytest.outcomes import fail
|
from _pytest.outcomes import fail
|
||||||
|
from _pytest.outcomes import skip
|
||||||
from _pytest.outcomes import TEST_OUTCOME
|
from _pytest.outcomes import TEST_OUTCOME
|
||||||
from _pytest.pathlib import absolutepath
|
from _pytest.pathlib import absolutepath
|
||||||
from _pytest.pathlib import bestrelpath
|
from _pytest.pathlib import bestrelpath
|
||||||
|
@ -1129,6 +1130,10 @@ def pytest_fixture_setup(
|
||||||
except TEST_OUTCOME:
|
except TEST_OUTCOME:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
assert exc_info[0] is not None
|
assert exc_info[0] is not None
|
||||||
|
if isinstance(
|
||||||
|
exc_info[1], skip.Exception
|
||||||
|
) and not fixturefunc.__name__.startswith("xunit_setup"):
|
||||||
|
exc_info[1]._use_item_location = True # type: ignore[attr-defined]
|
||||||
fixturedef.cached_result = (None, my_cache_key, exc_info)
|
fixturedef.cached_result = (None, my_cache_key, exc_info)
|
||||||
raise
|
raise
|
||||||
fixturedef.cached_result = (result, my_cache_key, None)
|
fixturedef.cached_result = (result, my_cache_key, None)
|
||||||
|
|
|
@ -1439,6 +1439,27 @@ def test_relpath_rootdir(pytester: Pytester) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_skip_from_fixture(pytester: Pytester) -> None:
|
||||||
|
pytester.makepyfile(
|
||||||
|
**{
|
||||||
|
"tests/test_1.py": """
|
||||||
|
import pytest
|
||||||
|
def test_pass(arg):
|
||||||
|
pass
|
||||||
|
@pytest.fixture
|
||||||
|
def arg():
|
||||||
|
condition = True
|
||||||
|
if condition:
|
||||||
|
pytest.skip("Fixture conditional skip")
|
||||||
|
""",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
result = pytester.runpytest("-rs", "tests/test_1.py", "--rootdir=tests")
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
["SKIPPED [[]1[]] tests/test_1.py:2: Fixture conditional skip"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_skip_using_reason_works_ok(pytester: Pytester) -> None:
|
def test_skip_using_reason_works_ok(pytester: Pytester) -> None:
|
||||||
p = pytester.makepyfile(
|
p = pytester.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue