Add returncode argument to pytest.exit

If the argument is not None, it'll raise a SystemExit exception to
cleanly exit pytest.
This commit is contained in:
Jose Carlos Menezes 2018-10-14 12:18:49 -03:00
parent 0be84cd68b
commit d7be039f1b
1 changed files with 5 additions and 2 deletions

View File

@ -57,9 +57,12 @@ class Exit(KeyboardInterrupt):
# exposed helper methods
def exit(msg):
def exit(msg, returncode=None):
""" exit testing process as if KeyboardInterrupt was triggered. """
__tracebackhide__ = True
if returncode:
raise SystemExit(returncode)
else:
raise Exit(msg)