Skip to content

Commit 35acacd

Browse files
committed
test: cover _require helper, show(), and _load_ui error paths in MainWindow
1 parent 2c52622 commit 35acacd

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/integration/test_main_window.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,45 @@ def test_merge_tab_has_coming_soon_label(self, window):
108108
label = window.ui.findChild(QLabel, "mergeComingSoonLabel")
109109
assert label is not None
110110
assert "coming soon" in label.text().lower()
111+
112+
113+
class TestRequireHelper:
114+
def test_raises_for_none_widget(self):
115+
from src.views.main_window import _require
116+
117+
with pytest.raises(RuntimeError, match="Required widget 'myWidget'"):
118+
_require(None, "myWidget")
119+
120+
def test_returns_widget_when_present(self):
121+
from src.views.main_window import _require
122+
123+
sentinel = object()
124+
assert _require(sentinel, "any") is sentinel
125+
126+
127+
class TestWindowShow:
128+
def test_show_does_not_raise(self, window):
129+
# Covers MainWindow.show() — line 81
130+
window.show()
131+
132+
133+
class TestLoadUiErrors:
134+
def test_raises_if_ui_file_unreadable(self, monkeypatch, qapp):
135+
from unittest.mock import MagicMock
136+
from src.views.main_window import MainWindow
137+
138+
monkeypatch.setattr(
139+
"src.views.main_window.QFile.open", lambda *_: False
140+
)
141+
with pytest.raises(RuntimeError, match="Cannot open UI file"):
142+
MainWindow(MagicMock())
143+
144+
def test_raises_if_loader_returns_none(self, monkeypatch, qapp):
145+
from unittest.mock import MagicMock
146+
from src.views.main_window import MainWindow
147+
148+
monkeypatch.setattr(
149+
"src.views.main_window.QUiLoader.load", lambda *_: None
150+
)
151+
with pytest.raises(RuntimeError, match="QUiLoader failed"):
152+
MainWindow(MagicMock())

0 commit comments

Comments
 (0)