Reputation: 563
I have following structure: Koholo job that calling python script, the script returns error code (1 - failed, 0 - passed) as it ends. Koholo wait for the error code to continue to next job step (next scrips). Now instead of python script I'm running pytest scrips (with command: python -m pytest test_name) but pytest is not returning error code, so the Kohola job timeouts. Please let me know if there is a way that pytest will return error code as it finish's?
Upvotes: 0
Views: 1272
Reputation: 1876
example you can pass any pytest argument that you normaly pass in the cli, i am just using the markers as an example
import sys
import pytest
results = pytest.main(["-m", "my_marker"])
sys.exit(results)
if you want more details https://docs.pytest.org/en/7.1.x/reference/exit-codes.html
Upvotes: 1
Reputation: 3661
when pytest finish it calls pytest_sessionfinish(session, exitstatus)
method.
try to add sys.exit(exitstatus)
to this method.
import sys
def pytest_sessionfinish(session, exitstatus):
""" whole test run finishes. """
sys.exit(exitstatus)
also you can check by running this script to check the exit code
start /wait python -m pytest test_name
echo %errorlevel%
Upvotes: 0