Skip to content

Commit 5338899

Browse files
authored
Hide Windows console when launching pg0
Merges the Windows console suppression fix for issue #32.
1 parent b8b8451 commit 5338899

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

sdk/python/pg0/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ def _run_pg0(*args: str, check: bool = True) -> subprocess.CompletedProcess:
143143
[pg0_path, *args],
144144
stdout=out_f,
145145
stderr=err_f,
146+
# pg0 is a console executable. Suppress the transient console
147+
# window when it is launched from a GUI Python application.
148+
creationflags=subprocess.CREATE_NO_WINDOW,
146149
)
147150
out_f.seek(0)
148151
err_f.seek(0)

sdk/python/tests/test_pg0.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import sys
77
import tempfile
88
import time
9+
from unittest.mock import patch
910

1011
import pytest
1112
import pg0
@@ -32,6 +33,19 @@ def clean_instance():
3233
class TestPg0:
3334
"""Tests for Pg0 class."""
3435

36+
@pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific subprocess flags")
37+
def test_windows_runner_hides_console_window(self):
38+
"""The Python wrapper must not create a console window for pg0.exe.
39+
40+
Regression test for https://github.com/vectorize-io/pg0/issues/32.
41+
"""
42+
with patch.object(pg0, "_find_pg0", return_value="pg0.exe"), patch.object(
43+
pg0.subprocess, "call", return_value=0
44+
) as call:
45+
pg0._run_pg0("start")
46+
47+
assert call.call_args.kwargs["creationflags"] == subprocess.CREATE_NO_WINDOW
48+
3549
def test_start_stop(self, clean_instance):
3650
"""Test starting and stopping Pg0."""
3751
pg = Pg0(name=TEST_NAME, port=TEST_PORT)

0 commit comments

Comments
 (0)