Fix custom theme handling for Qt6
This commit is contained in:
+7
-3
@@ -33,7 +33,7 @@ from PyQt6.QtWidgets import QMessageBox
|
||||
|
||||
sys.path.insert(1, str(Path(__file__).parent.parent.absolute()))
|
||||
|
||||
from novelwriter import CONFIG, SHARED, main # noqa: E402
|
||||
from novelwriter import CONFIG, SHARED # noqa: E402
|
||||
|
||||
from tests.mocked import MockGuiMain, MockTheme # noqa: E402
|
||||
from tests.tools import cleanProject # noqa: E402
|
||||
@@ -160,11 +160,15 @@ def mockGUI(qtbot, monkeypatch):
|
||||
@pytest.fixture(scope="function")
|
||||
def nwGUI(qtbot, monkeypatch, functionFixture):
|
||||
"""Create an instance of the novelWriter GUI."""
|
||||
from novelwriter.gui.theme import GuiTheme
|
||||
from novelwriter.guimain import GuiMain
|
||||
|
||||
monkeypatch.setattr(QMessageBox, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMessageBox, "result", lambda *a: QMessageBox.StandardButton.Yes)
|
||||
|
||||
nwGUI = main(["--testmode", f"--config={_TMP_CONF}", f"--data={_TMP_CONF}"])
|
||||
assert nwGUI is not None
|
||||
CONFIG.loadConfig()
|
||||
SHARED.initTheme(GuiTheme())
|
||||
nwGUI = GuiMain()
|
||||
qtbot.addWidget(nwGUI)
|
||||
resetConfigVars()
|
||||
nwGUI.docEditor.initEditor()
|
||||
|
||||
@@ -56,7 +56,8 @@ def testBaseSharedData_Init():
|
||||
assert mockGui is not mockTheme
|
||||
|
||||
# Properly initialise the class
|
||||
shared.initSharedData(mockGui, mockTheme) # type: ignore
|
||||
shared.initTheme(mockTheme) # type: ignore
|
||||
shared.initSharedData(mockGui) # type: ignore
|
||||
|
||||
assert shared.mainGui is mockGui
|
||||
assert shared.theme is mockTheme
|
||||
@@ -94,7 +95,8 @@ def testBaseSharedData_Projects(monkeypatch, caplog, fncPath):
|
||||
# Initialise the instance, should create an empty project
|
||||
mockGui = MockGuiMain()
|
||||
mockTheme = MockTheme()
|
||||
shared.initSharedData(mockGui, mockTheme) # type: ignore
|
||||
shared.initTheme(mockTheme) # type: ignore
|
||||
shared.initSharedData(mockGui) # type: ignore
|
||||
assert isinstance(shared.project, NWProject)
|
||||
assert shared.hasProject is False
|
||||
|
||||
@@ -150,7 +152,8 @@ def testBaseSharedData_Alerts(qtbot, monkeypatch, caplog):
|
||||
|
||||
mockGui = MockGuiMain()
|
||||
mockTheme = MockTheme()
|
||||
shared.initSharedData(mockGui, mockTheme) # type: ignore
|
||||
shared.initTheme(mockTheme) # type: ignore
|
||||
shared.initSharedData(mockGui) # type: ignore
|
||||
|
||||
assert shared.lastAlert == ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user