Skip to content

Commit

Permalink
Add returncode assertions
Browse files Browse the repository at this point in the history
Signed-off-by: ddelange <[email protected]>
  • Loading branch information
ddelange committed Dec 27, 2022
1 parent 338bbd0 commit 3352ac7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/cli/test_start_orion.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ def test_sigint_sends_sigterm_then_sigkill(self):
out += proc.stdout
out = "".join(line.decode() for line in out)

assert proc.returncode == 0, "The main process should exit gracefully"
assert re.search(
r"(Sending SIGTERM)(.|\s)*(Sending SIGKILL)", out
), "When sending two SIGINT shortly after each other, the main process should first send a SIGTERM and then a SIGKILL to the uvicorn process"
), "When sending two SIGINT shortly after each other, the main process should first send a SIGTERM and then a SIGKILL to the uvicorn subprocess"

@pytest.mark.skipif(
sys.platform == "win32",
Expand All @@ -71,9 +72,10 @@ def test_sigterm_sends_sigterm_then_sigkill(self):
out += proc.stdout
out = "".join(line.decode() for line in out)

assert proc.returncode == 0, "The main process should exit gracefully"
assert re.search(
r"(Sending SIGTERM)(.|\s)*(Sending SIGKILL)", out
), "When sending two SIGTERM shortly after each other, the main process should first send a SIGTERM and then a SIGKILL to the uvicorn process"
), "When sending two SIGTERM shortly after each other, the main process should first send a SIGTERM and then a SIGKILL to the uvicorn subprocess"

@pytest.mark.skipif(
sys.platform == "win32",
Expand All @@ -96,10 +98,10 @@ def test_sigterm_sends_sigterm_directly(self):
out += proc.stdout
out = "".join(line.decode() for line in out)

assert proc.returncode == 0, "The main process should exit gracefully"
assert re.search(
r"(Sending SIGTERM)(.|\s)*(Application shutdown complete)", out
), "When sending a SIGTERM, it should forward directly and exit gracefully"
assert proc.returncode == 0
), "When sending a SIGTERM, the main process should send a SIGTERM to the uvicorn subprocess"

@pytest.mark.skipif(
sys.platform != "win32",
Expand All @@ -122,6 +124,7 @@ def test_sends_ctrl_break_win32(self):
out += proc.stdout
out = "".join(line.decode() for line in out)

assert proc.returncode == 0, "The main process should exit gracefully"
assert re.search(
r"Sending CTRL_BREAK_EVENT", out
), "When sending a SIGINT, the main process should send a CTRL_BREAK_EVENT to the uvicorn process"
), "When sending a SIGINT, the main process should send a CTRL_BREAK_EVENT to the uvicorn subprocess"

0 comments on commit 3352ac7

Please sign in to comment.