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:
@@ -57,10 +57,13 @@ class Exit(KeyboardInterrupt):
|
||||
# exposed helper methods
|
||||
|
||||
|
||||
def exit(msg):
|
||||
def exit(msg, returncode=None):
|
||||
""" exit testing process as if KeyboardInterrupt was triggered. """
|
||||
__tracebackhide__ = True
|
||||
raise Exit(msg)
|
||||
if returncode:
|
||||
raise SystemExit(returncode)
|
||||
else:
|
||||
raise Exit(msg)
|
||||
|
||||
|
||||
exit.Exception = Exit
|
||||
|
||||
Reference in New Issue
Block a user