diff --git a/tests/test_base/test_base_error.py b/tests/test_base/test_base_error.py index 4d9990f2..05aff792 100644 --- a/tests/test_base/test_base_error.py +++ b/tests/test_base/test_base_error.py @@ -20,6 +20,8 @@ along with this program. If not, see . """ from __future__ import annotations +import sys + import pytest from novelwriter.error import NWErrorMessage, exceptionHandler @@ -29,8 +31,7 @@ from tests.mocked import causeException @pytest.mark.base def testBaseError_Dialog(qtbot, monkeypatch, nwGUI): - """Test the error dialog. - """ + """Test the error dialog.""" nwErr = NWErrorMessage(nwGUI) qtbot.addWidget(nwErr) nwErr.show() @@ -57,6 +58,14 @@ def testBaseError_Dialog(qtbot, monkeypatch, nwGUI): assert message != "" assert "(Unknown)" in message + # No enchant version retrieved + with monkeypatch.context() as mp: + mp.setitem(sys.modules, "enchant", None) + nwErr.setMessage(Exception, "Almost Fine Error", None) # type: ignore + message = nwErr.msgBody.toPlainText() + assert message != "" + assert "enchant: Unknown" in message + nwErr._doClose() nwErr.close() nwGUI.closeMain()