Add test for calling pytest.exit with statuscode

It checks that a SystemError was raised and the SystemError code
is the same as the returncode argument.
This commit is contained in:
Jose Carlos Menezes 2018-10-14 12:20:10 -03:00
parent d7be039f1b
commit ce55dcf64c
1 changed files with 9 additions and 0 deletions

View File

@ -570,6 +570,15 @@ def test_pytest_exit_msg(testdir):
result.stderr.fnmatch_lines(["Exit: oh noes"])
def test_pytest_exit_returncode():
try:
pytest.exit("hello", returncode=2)
except SystemExit as exc:
excinfo = _pytest._code.ExceptionInfo()
assert excinfo.errisinstance(SystemExit)
assert excinfo.value.code == 2
def test_pytest_fail_notrace_runtest(testdir):
"""Test pytest.fail(..., pytrace=False) does not show tracebacks during test run."""
testdir.makepyfile(