Add code changes back
This commit is contained in:
parent
1385ec117d
commit
f0586b12e6
|
@ -134,6 +134,10 @@ def runtestprotocol(
|
||||||
show_test_item(item)
|
show_test_item(item)
|
||||||
if not item.config.getoption("setuponly", False):
|
if not item.config.getoption("setuponly", False):
|
||||||
reports.append(call_and_report(item, "call", log))
|
reports.append(call_and_report(item, "call", log))
|
||||||
|
# If the session is about to fail or stop, teardown everything - this is
|
||||||
|
# necessary to correctly report fixture teardown errors (see #11706)
|
||||||
|
if item.session.shouldfail or item.session.shouldstop:
|
||||||
|
nextitem = None
|
||||||
reports.append(call_and_report(item, "teardown", log, nextitem=nextitem))
|
reports.append(call_and_report(item, "teardown", log, nextitem=nextitem))
|
||||||
# After all teardown hooks have been called
|
# After all teardown hooks have been called
|
||||||
# want funcargs and request info to go away.
|
# want funcargs and request info to go away.
|
||||||
|
|
|
@ -1216,3 +1216,53 @@ def test_pytest_version_env_var(pytester: Pytester, monkeypatch: MonkeyPatch) ->
|
||||||
result = pytester.runpytest_inprocess()
|
result = pytester.runpytest_inprocess()
|
||||||
assert result.ret == ExitCode.OK
|
assert result.ret == ExitCode.OK
|
||||||
assert os.environ["PYTEST_VERSION"] == "old version"
|
assert os.environ["PYTEST_VERSION"] == "old version"
|
||||||
|
|
||||||
|
|
||||||
|
def test_teardown_session_failed(pytester: Pytester) -> None:
|
||||||
|
"""Test that higher-scoped fixture teardowns run in the context of the last
|
||||||
|
item after the test session bails early due to --maxfail.
|
||||||
|
|
||||||
|
Regression test for #11706.
|
||||||
|
"""
|
||||||
|
pytester.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def baz():
|
||||||
|
yield
|
||||||
|
pytest.fail("This is a failing teardown")
|
||||||
|
|
||||||
|
def test_foo(baz):
|
||||||
|
pytest.fail("This is a failing test")
|
||||||
|
|
||||||
|
def test_bar(): pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = pytester.runpytest("--maxfail=1")
|
||||||
|
result.assert_outcomes(failed=1, errors=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_teardown_session_stopped(pytester: Pytester) -> None:
|
||||||
|
"""Test that higher-scoped fixture teardowns run in the context of the last
|
||||||
|
item after the test session bails early due to --stepwise.
|
||||||
|
|
||||||
|
Regression test for #11706.
|
||||||
|
"""
|
||||||
|
pytester.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def baz():
|
||||||
|
yield
|
||||||
|
pytest.fail("This is a failing teardown")
|
||||||
|
|
||||||
|
def test_foo(baz):
|
||||||
|
pytest.fail("This is a failing test")
|
||||||
|
|
||||||
|
def test_bar(): pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = pytester.runpytest("--stepwise")
|
||||||
|
result.assert_outcomes(failed=1, errors=1)
|
||||||
|
|
Loading…
Reference in New Issue