Skip to content

Commit 857d4d6

Browse files
authored
Refactor GUI test to use launch_app function
1 parent 1a16b2c commit 857d4d6

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

tests/test_gui.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
import subprocess
2-
import sys
31
import os
2+
import pytest
3+
from main import launch_app
44

5-
def test_main_runs():
6-
"""Check that main.py launches the GUI and exits without errors."""
5+
# Ensure Qt runs in offscreen mode (headless)
6+
os.environ["QT_QPA_PLATFORM"] = "offscreen"
7+
os.environ["AUTO_CLOSE_GUI"] = "1" # Auto-close GUI after 1 second
78

8-
main_path = os.path.join(os.path.dirname(__file__), "..", "main.py")
9-
assert os.path.exists(main_path), f"main.py not found at {main_path}"
10-
11-
env = os.environ.copy()
12-
env["PYTHONPATH"] = os.path.join(os.path.dirname(__file__), "..")
13-
env["AUTO_CLOSE_GUI"] = "1" # auto-close GUI after 1 second
14-
15-
result = subprocess.run(
16-
[sys.executable, main_path],
17-
capture_output=True,
18-
text=True,
19-
env=env
20-
)
21-
22-
assert result.returncode == 0, f"main.py failed with error:\n{result.stderr}"
9+
def test_main_launches():
10+
"""Test that main.py GUI launches and exits cleanly."""
11+
exit_code = launch_app(auto_close=True)
12+
assert exit_code == 0

0 commit comments

Comments
 (0)