Skip to content

Commit 17c031e

Browse files
committed
Handle Windows interrupt in non-interactive test
1 parent e802b5c commit 17c031e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/test_non_interactive.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,29 @@ def test_victoria_with_interrupt():
8181
try:
8282
python_cmd = sys.executable
8383

84+
# On Windows we need a process group to send CTRL_BREAK_EVENT
85+
creationflags = 0
86+
if platform.system() == 'Windows':
87+
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
88+
8489
# Start the process
8590
process = subprocess.Popen(
8691
[python_cmd, 'victoria.py'],
8792
stdin=subprocess.PIPE,
8893
stdout=subprocess.PIPE,
8994
stderr=subprocess.PIPE,
90-
text=True
95+
text=True,
96+
creationflags=creationflags
9197
)
92-
98+
9399
# Let it run for a moment
94100
time.sleep(1)
95-
101+
96102
# Send interrupt signal (Ctrl+C)
97-
process.send_signal(signal.SIGINT)
103+
if platform.system() == 'Windows':
104+
process.send_signal(signal.CTRL_BREAK_EVENT)
105+
else:
106+
process.send_signal(signal.SIGINT)
98107

99108
try:
100109
stdout, stderr = process.communicate(timeout=5)

0 commit comments

Comments
 (0)