From 050e3b09ad46c16703420e53363e1d6cdfac9f8c Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 5 Oct 2025 17:39:48 +0200 Subject: [PATCH] Fix test coverage --- novelwriter/guimain.py | 2 +- tests/test_gui/test_gui_guimain.py | 7 ++++--- tests/tools.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index ac065b03..acf6114b 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -498,7 +498,7 @@ class GuiMain(QMainWindow): # Check if we need to rebuild the index if SHARED.project.index.indexBroken: if not SHARED.project.index.indexUpgrade: - SHARED.info(self.tr("The project index is broken. Rebuilding index.")) + SHARED.warn(self.tr("The project index is broken. Rebuilding index.")) self.rebuildIndex() # Make sure the changed status is set to false on things opened diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py index 092a0486..0e15b71e 100644 --- a/tests/test_gui/test_gui_guimain.py +++ b/tests/test_gui/test_gui_guimain.py @@ -32,7 +32,8 @@ from PyQt6.QtCore import Qt from PyQt6.QtGui import QPalette from PyQt6.QtWidgets import QInputDialog, QMessageBox -from novelwriter import CONFIG, SHARED +from novelwriter import CONFIG, SHARED, __hexversion__ +from novelwriter.common import jsonEncode from novelwriter.config import DEF_GUI_DARK, DEF_GUI_LIGHT from novelwriter.constants import nwFiles from novelwriter.dialogs.editlabel import GuiEditLabel @@ -825,11 +826,11 @@ def testGuiMain_OpenClose(qtbot, monkeypatch, nwGUI, projPath, fncPath, mockRnd) nwGUI.viewDocument(C.hTitlePage) # Handle broken index on project open + idxData = jsonEncode({"novelWriter.meta": {"version": __hexversion__}}) nwGUI.closeProject() idxPath: Path = projPath / "meta" / nwFiles.INDEX_FILE assert idxPath.read_text(encoding="utf-8") != "{}" - idxPath.write_text("{}", encoding="utf-8") - assert idxPath.read_text(encoding="utf-8") == "{}" + idxPath.write_text(idxData, encoding="utf-8") nwGUI.openProject(projPath) nwGUI.saveProject() diff --git a/tests/tools.py b/tests/tools.py index 5d0b7c84..bca68899 100644 --- a/tests/tools.py +++ b/tests/tools.py @@ -67,7 +67,7 @@ def cmpFiles( fileOne: str | Path, fileTwo: str | Path, ignoreLines: list[int] | None = None, - ignoreStart: tuple[str] | None = None + ignoreStart: tuple | None = None ) -> bool: """Compare two files, with optional line ignore.""" if ignoreLines is None: