Skip to content

Commit 2e512c8

Browse files
committed
Use SIGINT in non-interactive test
1 parent 655db98 commit 2e512c8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test_non_interactive.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import time
1010
import platform
11+
import signal
1112

1213
# Fix Windows console encoding for Unicode characters
1314
if platform.system() == 'Windows':
@@ -92,21 +93,26 @@ def test_victoria_with_interrupt():
9293
# Let it run for a moment
9394
time.sleep(1)
9495

95-
# Send interrupt signal
96-
process.terminate()
96+
# Send interrupt signal (Ctrl+C)
97+
process.send_signal(signal.SIGINT)
9798

9899
try:
99100
stdout, stderr = process.communicate(timeout=5)
100101
exit_code = process.returncode
101102

102103
print(f" Exit code after interrupt: {exit_code}")
103-
104-
# Check for graceful interrupt handling
104+
105+
# Check for expected exit code and graceful interrupt handling
106+
if exit_code == 130:
107+
print(" ✓ Correct exit code (130) for SIGINT")
108+
else:
109+
print(f" ⚠️ Unexpected exit code: {exit_code}")
110+
105111
if "cancelled" in stdout.lower() or "interrupted" in stdout.lower():
106112
print(" ✓ Script handled interrupt gracefully")
107113
else:
108114
print(" ⚠️ No interrupt message found")
109-
115+
110116
return True
111117

112118
except subprocess.TimeoutExpired:
@@ -155,4 +161,4 @@ def main():
155161
return 1
156162

157163
if __name__ == "__main__":
158-
sys.exit(main())
164+
sys.exit(main())

0 commit comments

Comments
 (0)