Added spell check test

This commit is contained in:
Veronica K. B. Olsen
2020-09-10 23:02:12 +02:00
parent b79e63c9d3
commit 00c4404f9d
+51
View File
@@ -11,6 +11,7 @@ from nwtools import cmpFiles
from nw.core.project import NWProject
from nw.core.document import NWDoc
from nw.core.index import NWIndex
from nw.core.spellcheck import NWSpellEnchant, NWSpellSimple
from nw.constants import nwItemClass, nwItemLayout
@pytest.mark.project
@@ -321,3 +322,53 @@ def testDocMeta(nwDummy, nwLipsum):
assert thePath == []
assert theClass is None
assert theLayout is None
@pytest.mark.project
def testSpellEnchant(nwTemp, nwConf):
wList = path.join(nwTemp, "wordlist.txt")
with open(wList, mode="w") as wFile:
wFile.write("a_word\nb_word\nc_word\n")
spChk = NWSpellEnchant()
spChk.mainConf = nwConf
spChk.setLanguage("en", wList)
assert spChk.checkWord("a_word")
assert spChk.checkWord("b_word")
assert spChk.checkWord("c_word")
assert not spChk.checkWord("d_word")
spChk.addWord("d_word")
assert spChk.checkWord("d_word")
wSuggest = spChk.suggestWords("wrod")
assert len(wSuggest) > 0
assert "word" in wSuggest
dList = spChk.listDictionaries()
assert len(dList) > 0
@pytest.mark.project
def testSpellSimple(nwTemp, nwConf):
wList = path.join(nwTemp, "wordlist.txt")
with open(wList, mode="w") as wFile:
wFile.write("a_word\nb_word\nc_word\n")
spChk = NWSpellSimple()
spChk.mainConf = nwConf
spChk.setLanguage("en", wList)
assert spChk.checkWord("a_word")
assert spChk.checkWord("b_word")
assert spChk.checkWord("c_word")
assert not spChk.checkWord("d_word")
spChk.addWord("d_word")
assert spChk.checkWord("d_word")
wSuggest = spChk.suggestWords("wrod")
assert len(wSuggest) > 0
assert "word" in wSuggest
dList = spChk.listDictionaries()
assert len(dList) > 0