Spell check comments and docstrings

This commit is contained in:
Veronica Berglyd Olsen
2023-07-20 23:25:49 +02:00
parent e773884c29
commit 4dfa51855e
45 changed files with 122 additions and 175 deletions
+2 -2
View File
@@ -387,12 +387,12 @@ def testCoreBuildSettings_Collection(monkeypatch, mockGUI, fncPath: Path, mockRn
assert len(builds) == 0
assert not buildsFile.exists()
# Greate a default build
# Create a default build
buildOne = BuildSettings()
buildOne.setName("Build One")
buildIDOne = buildOne.buildID
# Check that invalid type is ahndled
# Check that invalid type is handled
builds.setBuild(None) # type: ignore
assert len(builds) == 0
assert not buildsFile.exists()
+4 -4
View File
@@ -76,7 +76,7 @@ BUILD_CONF = {
@pytest.mark.core
def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
"""Test builing an open document manuscript."""
"""Test building an open document manuscript."""
project = NWProject(mockGUI)
project.openProject(prjLipsum)
@@ -180,7 +180,7 @@ def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstP
@pytest.mark.core
def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
"""Test builing an HTML manuscript."""
"""Test building an HTML manuscript."""
project = NWProject(mockGUI)
project.openProject(prjLipsum)
@@ -250,7 +250,7 @@ def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
@pytest.mark.core
def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
"""Test builing an Markdown manuscript."""
"""Test building an Markdown manuscript."""
project = NWProject(mockGUI)
project.openProject(prjLipsum)
@@ -320,7 +320,7 @@ def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths
@pytest.mark.core
def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
"""Test builing a NWD manuscript."""
"""Test building a NWD manuscript."""
project = NWProject(mockGUI)
project.openProject(prjLipsum)
+10 -16
View File
@@ -35,7 +35,7 @@ from novelwriter.core.project import NWProject
@pytest.mark.core
def testCoreIndex_LoadSave(monkeypatch, prjLipsum, mockGUI, tstPaths):
"""Test core functionality of scaning, saving, loading and checking
"""Test core functionality of scanning, saving, loading and checking
the index cache file.
"""
projFile = prjLipsum / "meta" / nwFiles.INDEX_FILE
@@ -154,8 +154,7 @@ def testCoreIndex_LoadSave(monkeypatch, prjLipsum, mockGUI, tstPaths):
@pytest.mark.core
def testCoreIndex_ScanThis(mockGUI):
"""Test the tag scanner function scanThis.
"""
"""Test the tag scanner function scanThis."""
theProject = NWProject(mockGUI)
theIndex = theProject.index
@@ -281,8 +280,7 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreIndex_ScanText(mockGUI, fncPath, mockRnd):
"""Check the index text scanner.
"""
"""Check the index text scanner."""
theProject = NWProject(mockGUI)
mockRnd.reset()
buildTestProject(theProject, fncPath)
@@ -503,8 +501,7 @@ def testCoreIndex_ScanText(mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
"""Check the index data extraction functions.
"""
"""Check the index data extraction functions."""
theProject = NWProject(mockGUI)
mockRnd.reset()
buildTestProject(theProject, fncPath)
@@ -591,7 +588,7 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
# getReferences
# =============
# Look up an ivalid handle
# Look up an invalid handle
theRefs = theIndex.getReferences("Not a handle")
assert theRefs["@pov"] == []
assert theRefs["@char"] == []
@@ -784,8 +781,7 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreIndex_TagsIndex():
"""Check the TagsIndex class.
"""
"""Check the TagsIndex class."""
tagsIndex = TagsIndex()
assert tagsIndex._tags == {}
@@ -847,7 +843,7 @@ def testCoreIndex_TagsIndex():
# Pack Data
assert tagsIndex.packData() == content
# Delete the second key and a nomn-existant key
# Delete the second key and a non-existant key
del tagsIndex["Tag2"]
del tagsIndex["Tag4"]
assert "Tag1" in tagsIndex
@@ -944,8 +940,7 @@ def testCoreIndex_TagsIndex():
@pytest.mark.core
def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
"""Check the ItemIndex class.
"""
"""Check the ItemIndex class."""
theProject = NWProject(mockGUI)
mockRnd.reset()
buildTestProject(theProject, fncPath)
@@ -981,7 +976,7 @@ def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
# Add a heading to an invalid item
assert itemIndex.addItemHeading(C.hInvalid, 1, "H1", "Stuff") == "T0000"
# Set the remainig data values
# Set the remaining data values
itemIndex.setHeadingCounts(cHandle, "T0001", 60, 10, 2)
itemIndex.setHeadingSynopsis(cHandle, "T0001", "In the beginning ...")
itemIndex.setHeadingTag(cHandle, "T0001", "One")
@@ -1183,8 +1178,7 @@ def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreIndex_CountWords():
"""Test the word counter and the exclusion filers.
"""
"""Test the word counter and the exclusion filers."""
# Non-Text
assert countWords(None) == (0, 0, 0)
assert countWords(1234) == (0, 0, 0)
+9 -15
View File
@@ -38,8 +38,7 @@ from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLR
@pytest.mark.core
def testCoreProject_NewRoot(fncPath, tstPaths, mockGUI, mockRnd):
"""Check that new root folders can be added to the project.
"""
"""Check that new root folders can be added to the project."""
projFile = fncPath / "nwProject.nwx"
testFile = tstPaths.outDir / "coreProject_NewRoot_nwProject.nwx"
compFile = tstPaths.refDir / "coreProject_NewRoot_nwProject.nwx"
@@ -89,8 +88,7 @@ def testCoreProject_NewRoot(fncPath, tstPaths, mockGUI, mockRnd):
@pytest.mark.core
def testCoreProject_NewFileFolder(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd):
"""Check that new files can be added to the project.
"""
"""Check that new files can be added to the project."""
projFile = fncPath / "nwProject.nwx"
testFile = tstPaths.outDir / "coreProject_NewFileFolder_nwProject.nwx"
compFile = tstPaths.refDir / "coreProject_NewFileFolder_nwProject.nwx"
@@ -163,8 +161,7 @@ def testCoreProject_NewFileFolder(monkeypatch, fncPath, tstPaths, mockGUI, mockR
@pytest.mark.core
def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd):
"""Test opening a project.
"""
"""Test opening a project."""
theProject = NWProject(mockGUI)
mockRnd.reset()
buildTestProject(theProject, fncPath)
@@ -259,8 +256,7 @@ def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath):
"""Test saving a project.
"""
"""Test saving a project."""
theProject = NWProject(mockGUI)
# Nothing to save
@@ -289,8 +285,7 @@ def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath):
@pytest.mark.core
def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd):
"""Test helper functions for the project folder.
"""
"""Test helper functions for the project folder."""
theProject = NWProject(mockGUI)
buildTestProject(theProject, fncPath)
@@ -354,8 +349,7 @@ def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreProject_StatusImport(mockGUI, fncPath, mockRnd):
"""Test the status and importance flag handling.
"""
"""Test the status and importance flag handling."""
theProject = NWProject(mockGUI)
mockRnd.reset()
buildTestProject(theProject, fncPath)
@@ -506,7 +500,7 @@ def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd):
assert theProject.data.spellLang is None
theProject.data.setSpellLang(None)
assert theProject.data.spellLang is None
theProject.data.setSpellLang("None") # Should be interpreded as None
theProject.data.setSpellLang("None") # Should be interpreted as None
assert theProject.data.spellLang is None
theProject.data.setSpellLang("en_GB")
assert theProject.data.spellLang == "en_GB"
@@ -589,7 +583,7 @@ def testCoreProject_OrphanedFiles(mockGUI, prjLipsum):
assert theProject.tree["636b6aa9b697b"] is None
# Add a file with non-existent parent
# This file will be renoved from the project on open
# This file will be removed from the project on open
oHandle = theProject.newFile("Oops", "b3643d0f92e32")
theProject.tree[oHandle].setParent("1234567890abc")
@@ -663,7 +657,7 @@ def testCoreProject_OrphanedFiles(mockGUI, prjLipsum):
def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths):
"""Test the automated backup feature of the project class. The test
creates a backup of the Minimal test project, and then unzips the
backupd file and checks that the project XML file is identical to
backup file and checks that the project XML file is identical to
the original file.
"""
theProject = NWProject(mockGUI)
+2 -3
View File
@@ -89,7 +89,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
assert xmlReader.read(data, content) is False
assert xmlReader.state == XMLReadState.UNKNOWN_VERSION
# Check parsing of unkown sections
# Check parsing of unknown sections
writeFile(xmlFile, (
"<novelWriterXML fileVersion='1.5'>"
" <project>"
@@ -243,8 +243,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
@pytest.mark.core
def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
"""Test reading the version 1.0 XML file format.
"""
"""Test reading the version 1.0 XML file format."""
refFile = tstPaths.filesDir / "nwProject-1.0.nwx"
xmlFile = fncPath / "nwProject-1.0.nwx"
outFile = fncPath / "nwProject.nwx"
+1 -1
View File
@@ -41,7 +41,7 @@ def testCoreSessions_Main(monkeypatch, mockGUI, fncPath):
logFile = project.storage.getMetaFile(nwFiles.SESS_FILE)
assert isinstance(logFile, Path)
# Set some moch word counts
# Set some mock word counts
project.data.setInitCounts(50, 60)
project.data.setCurrCounts(160, 150)
+11 -20
View File
@@ -35,8 +35,7 @@ class BareTokenizer(Tokenizer):
@pytest.mark.core
def testCoreToken_Setters(mockGUI):
"""Test all the setters for the Tokenizer class.
"""
"""Test all the setters for the Tokenizer class."""
theProject = NWProject(mockGUI)
theToken = BareTokenizer(theProject)
@@ -133,8 +132,7 @@ def testCoreToken_Setters(mockGUI):
@pytest.mark.core
def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
"""Test handling files and text in the Tokenizer class.
"""
"""Test handling files and text in the Tokenizer class."""
theProject = NWProject(mockGUI)
mockRnd.reset()
buildTestProject(theProject, fncPath)
@@ -212,7 +210,7 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
"# Notes: Plot\n\n"
)
# Ckeck abstract method
# Check abstract method
with pytest.raises(NotImplementedError):
theToken.doConvert()
@@ -221,8 +219,7 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
@pytest.mark.core
def testCoreToken_StripEscape():
"""Test the stripEscape helper function.
"""
"""Test the stripEscape helper function."""
text1 = "This is text with escapes: \\** \\~~ \\__"
text2 = "This is text with escapes: ** ~~ __"
assert stripEscape(text1) == "This is text with escapes: ** ~~ __"
@@ -233,8 +230,7 @@ def testCoreToken_StripEscape():
@pytest.mark.core
def testCoreToken_HeaderFormat(mockGUI):
"""Test the tokenization of header formats in the Tokenizer class.
"""
"""Test the tokenization of header formats in the Tokenizer class."""
theProject = NWProject(mockGUI)
theToken = BareTokenizer(theProject)
theToken.setKeepMarkdown(True)
@@ -437,8 +433,7 @@ def testCoreToken_HeaderFormat(mockGUI):
@pytest.mark.core
def testCoreToken_MetaFormat(mockGUI):
"""Test the tokenization of meta formats in the Tokenizer class.
"""
"""Test the tokenization of meta formats in the Tokenizer class."""
theProject = NWProject(mockGUI)
theToken = BareTokenizer(theProject)
theToken.setKeepMarkdown(True)
@@ -456,7 +451,7 @@ def testCoreToken_MetaFormat(mockGUI):
theToken.tokenizeText()
assert theToken.theMarkdown[-1] == "% A comment\n\n"
# Symopsis
# Synopsis
theToken._text = "%synopsis: The synopsis\n"
theToken.tokenizeText()
assert theToken._tokens == [
@@ -506,8 +501,7 @@ def testCoreToken_MetaFormat(mockGUI):
@pytest.mark.core
def testCoreToken_MarginFormat(mockGUI):
"""Test the tokenization of margin formats in the Tokenizer class.
"""
"""Test the tokenization of margin formats in the Tokenizer class."""
theProject = NWProject(mockGUI)
theToken = BareTokenizer(theProject)
theToken.setKeepMarkdown(True)
@@ -561,8 +555,7 @@ def testCoreToken_MarginFormat(mockGUI):
@pytest.mark.core
def testCoreToken_TextFormat(mockGUI):
"""Test the tokenization of text formats in the Tokenizer class.
"""
"""Test the tokenization of text formats in the Tokenizer class."""
theProject = NWProject(mockGUI)
theToken = BareTokenizer(theProject)
theToken.setKeepMarkdown(True)
@@ -683,8 +676,7 @@ def testCoreToken_TextFormat(mockGUI):
@pytest.mark.core
def testCoreToken_SpecialFormat(mockGUI):
"""Test the tokenization of special formats in the Tokenizer class.
"""
"""Test the tokenization of special formats in the Tokenizer class."""
theProject = NWProject(mockGUI)
theToken = BareTokenizer(theProject)
@@ -886,8 +878,7 @@ def testCoreToken_SpecialFormat(mockGUI):
@pytest.mark.core
def testCoreToken_ProcessHeaders(mockGUI):
"""Test the header and page parser of the Tokenizer class.
"""
"""Test the header and page parser of the Tokenizer class."""
theProject = NWProject(mockGUI)
theProject.data.setLanguage("en")
theProject._loadProjectLocalisation()
+5 -7
View File
@@ -29,7 +29,8 @@ from novelwriter.core.project import NWProject
@pytest.mark.core
def testCoreToMarkdown_ConvertFormat(mockGUI):
"""Test the tokenizer and converter chain using the ToMarkdown class.
"""Test the tokenizer and converter chain using the ToMarkdown
class.
"""
theProject = NWProject(mockGUI)
theMD = ToMarkdown(theProject)
@@ -157,8 +158,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
@pytest.mark.core
def testCoreToMarkdown_ConvertDirect(mockGUI):
"""Test the converter directly using the ToMarkdown class.
"""
"""Test the converter directly using the ToMarkdown class."""
theProject = NWProject(mockGUI)
theMD = ToMarkdown(theProject)
@@ -208,8 +208,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
@pytest.mark.core
def testCoreToMarkdown_Complex(mockGUI, fncPath):
"""Test the save method of the ToMarkdown class.
"""
"""Test the save method of the ToMarkdown class."""
theProject = NWProject(mockGUI)
theMD = ToMarkdown(theProject)
theMD._isNovel = True
@@ -261,8 +260,7 @@ def testCoreToMarkdown_Complex(mockGUI, fncPath):
@pytest.mark.core
def testCoreToMarkdown_Format(mockGUI):
"""Test all the formatters for the ToMarkdown class.
"""
"""Test all the formatters for the ToMarkdown class."""
theProject = NWProject(mockGUI)
theMD = ToMarkdown(theProject)
+8 -16
View File
@@ -36,8 +36,7 @@ from novelwriter.core.project import NWProject
@pytest.fixture(scope="function")
def mockItems(mockGUI, mockRnd):
"""Create a list of mock items.
"""
"""Create a list of mock items."""
theProject = NWProject(mockGUI)
itemA = NWItem(theProject)
@@ -113,8 +112,7 @@ def mockItems(mockGUI, mockRnd):
@pytest.mark.core
def testCoreTree_BuildTree(mockGUI, mockItems):
"""Test building a project tree from a list of items.
"""
"""Test building a project tree from a list of items."""
theProject = NWProject(mockGUI)
theTree = NWTree(theProject)
@@ -232,8 +230,7 @@ def testCoreTree_BuildTree(mockGUI, mockItems):
@pytest.mark.core
def testCoreTree_PackUnpack(mockGUI, mockItems):
"""Test packing and unpacking data.
"""
"""Test packing and unpacking data."""
theProject = NWProject(mockGUI)
theTree = NWTree(theProject)
@@ -262,8 +259,7 @@ def testCoreTree_PackUnpack(mockGUI, mockItems):
@pytest.mark.core
def testCoreTree_Methods(mockGUI, mockItems):
"""Test various class methods.
"""
"""Test various class methods."""
theProject = NWProject(mockGUI)
theTree = NWTree(theProject)
@@ -343,8 +339,7 @@ def testCoreTree_Methods(mockGUI, mockItems):
@pytest.mark.core
def testCoreTree_MakeHandles(mockGUI):
"""Test generating item handles.
"""
"""Test generating item handles."""
random.seed(42)
theProject = NWProject(mockGUI)
theTree = NWTree(theProject)
@@ -373,8 +368,7 @@ def testCoreTree_MakeHandles(mockGUI):
@pytest.mark.core
def testCoreTree_Stats(mockGUI, mockItems):
"""Test project stats methods.
"""
"""Test project stats methods."""
theProject = NWProject(mockGUI)
theTree = NWTree(theProject)
@@ -394,8 +388,7 @@ def testCoreTree_Stats(mockGUI, mockItems):
@pytest.mark.core
def testCoreTree_Reorder(caplog, mockGUI, mockItems):
"""Test changing tree order.
"""
"""Test changing tree order."""
theProject = NWProject(mockGUI)
theTree = NWTree(theProject)
@@ -430,8 +423,7 @@ def testCoreTree_Reorder(caplog, mockGUI, mockItems):
@pytest.mark.core
def testCoreTree_ToCFile(monkeypatch, tstPaths, mockGUI, mockItems):
"""Test writing the ToC.txt file.
"""
"""Test writing the ToC.txt file."""
theProject = NWProject(mockGUI)
theTree = NWTree(theProject)