Update test coverage

This commit is contained in:
Veronica Berglyd Olsen
2025-06-13 21:37:31 +02:00
parent e3eea2628a
commit 9384b8a6b9
5 changed files with 42 additions and 13 deletions
+15 -1
View File
@@ -34,6 +34,8 @@ from PyQt6.QtWidgets import QMessageBox
sys.path.insert(1, str(Path(__file__).parent.parent.absolute()))
from novelwriter import CONFIG, SHARED
from novelwriter.config import DEF_GUI_DARK, DEF_GUI_LIGHT
from novelwriter.enum import nwTheme
from tests.mocked import MockGuiMain
from tests.tools import cleanProject
@@ -60,6 +62,10 @@ def resetConfigVars():
CONFIG._dLocale = QLocale("en_GB")
CONFIG._manuals = {"manual": _TMP_ROOT / "manual.pdf"}
CONFIG.guiLocale = "en_GB"
CONFIG.darkTheme = DEF_GUI_DARK
CONFIG.lightTheme = DEF_GUI_LIGHT
CONFIG.themeMode = nwTheme.LIGHT
CONFIG.emphLabels = True # Ensures better coverage, off by default
return
@@ -157,13 +163,21 @@ def mockGUI(qtbot, monkeypatch):
monkeypatch.setattr(QMessageBox, "result", lambda *a: QMessageBox.StandardButton.Yes)
gui = MockGuiMain()
theme = GuiTheme()
theme.loadTheme()
monkeypatch.setattr(SHARED, "_gui", gui)
monkeypatch.setattr(SHARED, "_theme", theme)
return gui
@pytest.fixture(scope="function")
def mockGUIwithTheme(mockGUI):
"""Create a mock instance of novelWriter's main GUI class with the
theme instance initialised.
"""
SHARED.theme.initThemes()
return mockGUI
@pytest.fixture(scope="function")
def nwGUI(qtbot, monkeypatch, functionFixture):
"""Create an instance of the novelWriter GUI."""