File tree Expand file tree Collapse file tree 1 file changed +9
-19
lines changed
Expand file tree Collapse file tree 1 file changed +9
-19
lines changed Original file line number Diff line number Diff line change 1- import subprocess
2- import sys
31import 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
You can’t perform that action at this time.
0 commit comments