Skip to content

Commit 756836b

Browse files
committed
Use fixtures to control SHOW_SPLASH in tests
Replace the autouse fixture with explicit fixtures to toggle dlclivegui.gui.theme.SHOW_SPLASH per-test. Adds set_use_splash_true and set_use_splash_false fixtures, updates tests to accept them, and removes the manual SHOW_SPLASH override in test_main_without_splash. Also fixes a comment typo (thems.py -> theme.py) to make splash behavior explicit and avoid cross-test side effects.
1 parent 6d21bd2 commit 756836b

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

tests/gui/test_app_entrypoint.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,20 @@ def _import_fresh():
2424
return importlib.import_module(MODULE_UNDER_TEST)
2525

2626

27-
@pytest.fixture(autouse=True)
27+
@pytest.fixture
2828
def set_use_splash_true(monkeypatch):
29-
# Ensure thems.py SHOW_SPLASH is True for tests that rely on it, without affecting other tests
29+
# Ensure theme.py SHOW_SPLASH is True for tests that rely on it, without affecting other tests
3030
monkeypatch.setattr("dlclivegui.gui.theme.SHOW_SPLASH", True)
3131

3232

33+
@pytest.fixture
34+
def set_use_splash_false(monkeypatch):
35+
# Ensure theme.py SHOW_SPLASH is False for tests that rely on it, without affecting other tests
36+
monkeypatch.setattr("dlclivegui.gui.theme.SHOW_SPLASH", False)
37+
38+
3339
@pytest.mark.gui
34-
def test_main_with_splash(monkeypatch):
40+
def test_main_with_splash(monkeypatch, set_use_splash_true):
3541
appmod = _import_fresh()
3642

3743
# --- Patch Qt app & icon in the entry module's namespace ---
@@ -101,7 +107,7 @@ def immediate_single_shot(ms, fn):
101107

102108

103109
@pytest.mark.gui
104-
def test_main_without_splash(monkeypatch):
110+
def test_main_without_splash(monkeypatch, set_use_splash_false):
105111
appmod = _import_fresh()
106112

107113
# Patch Qt app creation & window icon
@@ -111,9 +117,6 @@ def test_main_without_splash(monkeypatch):
111117
monkeypatch.setattr(appmod, "QApplication", QApplication_cls)
112118
monkeypatch.setattr(appmod, "QIcon", MagicMock(name="QIcon"))
113119

114-
# Force the no-splash branch
115-
appmod.SHOW_SPLASH = False
116-
117120
# show_splash should not be called
118121
show_splash_mock = MagicMock(name="show_splash")
119122
monkeypatch.setattr(appmod, "show_splash", show_splash_mock)

0 commit comments

Comments
 (0)