Move spell check testing to the editor
This commit is contained in:
@@ -21,7 +21,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
@@ -30,7 +29,7 @@ import pytest
|
||||
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtGui import QPalette
|
||||
from PyQt6.QtWidgets import QInputDialog, QMenu, QMessageBox
|
||||
from PyQt6.QtWidgets import QInputDialog, QMessageBox
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.constants import nwFiles
|
||||
@@ -569,28 +568,28 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
||||
# Spell Checking
|
||||
# ==============
|
||||
|
||||
for c in "Some text with tesst in it.":
|
||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||
# for c in "Some text with tesst in it.":
|
||||
# qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||
# qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||
# qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||
|
||||
currPos = docEditor.getCursorPosition()
|
||||
assert docEditor._qDocument.spellErrorAtPos(currPos) == ("", -1, -1, [])
|
||||
# currPos = docEditor.getCursorPosition()
|
||||
# assert docEditor._qDocument.spellErrorAtPos(currPos) == ("", -1, -1, [])
|
||||
|
||||
errPos = currPos - 13
|
||||
if not sys.platform.startswith("win32"):
|
||||
# Skip on Windows as spell checking is off there
|
||||
# This check will fail without an 'en' dictionary, like aspell-en
|
||||
word, cPos, cLen, suggest = docEditor._qDocument.spellErrorAtPos(errPos)
|
||||
assert word == "tesst"
|
||||
assert cPos == 15
|
||||
assert cLen == 5
|
||||
assert "test" in suggest
|
||||
# errPos = currPos - 13
|
||||
# if not sys.platform.startswith("win32"):
|
||||
# # Skip on Windows as spell checking is off there
|
||||
# # This check will fail without an 'en' dictionary, like aspell-en
|
||||
# word, cPos, cLen, suggest = docEditor._qDocument.spellErrorAtPos(errPos)
|
||||
# assert word == "tesst"
|
||||
# assert cPos == 15
|
||||
# assert cLen == 5
|
||||
# assert "test" in suggest
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QMenu, "exec", lambda *a: None)
|
||||
docEditor.setCursorPosition(errPos)
|
||||
docEditor._openContextFromCursor()
|
||||
# with monkeypatch.context() as mp:
|
||||
# mp.setattr(QMenu, "exec", lambda *a: None)
|
||||
# docEditor.setCursorPosition(errPos)
|
||||
# docEditor._openContextFromCursor()
|
||||
|
||||
# Check Files
|
||||
# ===========
|
||||
|
||||
Reference in New Issue
Block a user