Add coverage of some missed lines

This commit is contained in:
Veronica Berglyd Olsen
2023-12-30 16:52:24 +01:00
parent bc17305c4f
commit 05e9729c22
5 changed files with 20 additions and 12 deletions
+7 -2
View File
@@ -25,7 +25,7 @@ import pytest
from tools import buildTestProject
from mocked import MockGuiMain, MockTheme
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtWidgets import QFileDialog, QMessageBox, QWidget
from novelwriter.shared import SharedData
from novelwriter.core.project import NWProject
@@ -66,7 +66,7 @@ def testBaseSharedData_Init():
@pytest.mark.base
def testBaseSharedData_Projects(fncPath, caplog):
def testBaseSharedData_Projects(monkeypatch, caplog, fncPath):
"""Test SharedData handling of projects."""
project = NWProject()
buildTestProject(project, fncPath)
@@ -118,6 +118,11 @@ def testBaseSharedData_Projects(fncPath, caplog):
assert shared.hasProject is False
assert isinstance(shared.projectLock, list)
# Test browsing for projects
with monkeypatch.context() as mp:
mp.setattr(QFileDialog, "getOpenFileName", lambda *a, **k: (a[2], ""))
assert shared.getProjectPath(QWidget(), fncPath, allowZip=True) == fncPath
# END Test testBaseSharedData_Projects