File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 88import sys
99import time
1010import platform
11+ import signal
1112
1213# Fix Windows console encoding for Unicode characters
1314if 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
157163if __name__ == "__main__" :
158- sys .exit (main ())
164+ sys .exit (main ())
You can’t perform that action at this time.
0 commit comments