MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_wrap_session_exit_sessionfinish

Function test_wrap_session_exit_sessionfinish

testing/test_main.py:66–84  ·  view source on GitHub ↗
(
    returncode: Optional[int], pytester: Pytester
)

Source from the content-addressed store, hash-verified

64
65@pytest.mark.parametrize("returncode", (None, 42))
66def test_wrap_session_exit_sessionfinish(
67 returncode: Optional[int], pytester: Pytester
68) -> None:
69 pytester.makeconftest(
70 """
71 import pytest
72 def pytest_sessionfinish():
73 pytest.exit(reason="exit_pytest_sessionfinish", returncode={returncode})
74 """.format(
75 returncode=returncode
76 )
77 )
78 result = pytester.runpytest()
79 if returncode:
80 assert result.ret == returncode
81 else:
82 assert result.ret == ExitCode.NO_TESTS_COLLECTED
83 assert result.stdout.lines[-1] == "collected 0 items"
84 assert result.stderr.lines == ["Exit: exit_pytest_sessionfinish"]
85
86
87@pytest.mark.parametrize("basetemp", ["foo", "foo/bar"])

Callers

nothing calls this directly

Calls 3

makeconftestMethod · 0.45
formatMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected