Remove caching of the alert object in the shared instance

This commit is contained in:
Veronica Berglyd Olsen
2023-11-29 16:03:48 +01:00
parent 1edfcfcd91
commit 1d1dae0c7e
5 changed files with 60 additions and 75 deletions
+4 -6
View File
@@ -44,8 +44,7 @@ def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath):
with monkeypatch.context() as mp:
mp.setattr(enchant, "get_user_config_dir", lambda *a: causeException)
nwGUI.showDictionariesDialog()
assert SHARED.alert is not None
assert SHARED.alert.logMessage == "Could not initialise the dialog."
assert SHARED.lastAlert == "Could not initialise the dialog."
# Open the tool
nwGUI.showDictionariesDialog()
@@ -57,17 +56,16 @@ def testToolDictionaries_Main(qtbot, monkeypatch, nwGUI, fncPath):
assert nwDicts.inPath.text() == str(fncPath)
# Allow Open Dir
SHARED._alert = None
SHARED._lastAlert = ""
with monkeypatch.context() as mp:
mp.setattr(QDesktopServices, "openUrl", lambda *a: None)
nwDicts._doOpenInstallLocation()
assert SHARED.alert is None
assert SHARED.lastAlert == ""
# Fail Open Dir
nwDicts.inPath.setText("/foo/bar")
nwDicts._doOpenInstallLocation()
assert SHARED.alert is not None
assert SHARED.alert.logMessage == "Path not found."
assert SHARED.lastAlert == "Path not found."
nwDicts.inPath.setText(str(fncPath))
# Create Mock Dicts