Spell check comments and docstrings
This commit is contained in:
@@ -133,7 +133,7 @@ def testBaseCommon_CheckBool():
|
||||
assert checkBool(0, True) is False
|
||||
assert checkBool(1, False) is True
|
||||
|
||||
# Inalid Integers
|
||||
# Invalid Integers
|
||||
assert checkBool(2, True) is True
|
||||
assert checkBool(2, False) is False
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ from novelwriter.constants import nwFiles
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseConfig_Constructor(monkeypatch):
|
||||
"""Test config contructor.
|
||||
"""
|
||||
"""Test config constructor."""
|
||||
# Linux
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("sys.platform", "linux")
|
||||
@@ -93,8 +92,7 @@ def testBaseConfig_Constructor(monkeypatch):
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths):
|
||||
"""Test config intialisation.
|
||||
"""
|
||||
"""Test config initialisation."""
|
||||
tstConf = Config()
|
||||
|
||||
confFile = fncPath / nwFiles.CONF_FILE
|
||||
@@ -159,8 +157,7 @@ def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths):
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseConfig_Localisation(fncPath, tstPaths):
|
||||
"""Test localisation.
|
||||
"""
|
||||
"""Test localisation."""
|
||||
tstConf = Config()
|
||||
tstConf.initConfig(confPath=fncPath, dataPath=fncPath)
|
||||
|
||||
@@ -198,8 +195,7 @@ def testBaseConfig_Localisation(fncPath, tstPaths):
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseConfig_Methods(fncPath):
|
||||
"""Check class methods.
|
||||
"""
|
||||
"""Check class methods."""
|
||||
tstConf = Config()
|
||||
tstConf.initConfig(confPath=fncPath, dataPath=fncPath)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ def testBaseError_Dialog(qtbot, monkeypatch, nwGUI):
|
||||
def testBaseError_Handler(qtbot, monkeypatch, nwGUI):
|
||||
"""Test the error handler. This test doesn'thave any asserts, but it
|
||||
checks that the error handler handles potential exceptions. The test
|
||||
will fail if excpetions are not handled.
|
||||
will fail if exceptions are not handled.
|
||||
"""
|
||||
# Normal shutdown
|
||||
with monkeypatch.context() as mp:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ from novelwriter.dialogs.about import GuiAbout
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
||||
"""Test the novelWriter about dialogs.
|
||||
"""
|
||||
"""Test the novelWriter about dialogs."""
|
||||
# NW About
|
||||
nwGUI.mainTheme.themeName = "A Theme"
|
||||
nwGUI.mainTheme.themeAuthor = "An Author"
|
||||
@@ -72,12 +71,11 @@ def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgAbout_QtDialog(monkeypatch, nwGUI):
|
||||
"""Test the Qt about dialogs.
|
||||
"""
|
||||
"""Test the Qt about dialogs."""
|
||||
monkeypatch.setattr(QMessageBox, "aboutQt", lambda *a, **k: None)
|
||||
|
||||
# Open About
|
||||
# All it can do is check aigainst a crash
|
||||
# All it can do is check against a crash
|
||||
assert nwGUI.showAboutQtDialog() is True
|
||||
nwGUI.mainMenu.aAboutQt.activate(QAction.Trigger)
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
||||
"""Test the quote symbols dialog.
|
||||
"""
|
||||
"""Test the quote symbols dialog."""
|
||||
nwQuot = GuiQuoteSelect(nwGUI)
|
||||
nwQuot.show()
|
||||
|
||||
@@ -58,8 +57,7 @@ def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
|
||||
"""Test the check for updates dialog.
|
||||
"""
|
||||
"""Test the check for updates dialog."""
|
||||
nwUpdate = GuiUpdates(nwGUI)
|
||||
nwUpdate.show()
|
||||
|
||||
@@ -97,8 +95,7 @@ def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgOther_EditLabel(qtbot, monkeypatch):
|
||||
"""Test the label editor dialog.
|
||||
"""
|
||||
"""Test the label editor dialog."""
|
||||
monkeypatch.setattr(GuiEditLabel, "exec_", lambda *a: None)
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
|
||||
@@ -29,8 +29,7 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
"""Test the split document tool.
|
||||
"""
|
||||
"""Test the split document tool."""
|
||||
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
|
||||
|
||||
# Create a new project
|
||||
@@ -64,7 +63,7 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
nwSplit.show()
|
||||
qtbot.addWidget(nwSplit)
|
||||
|
||||
# By default, only up to level three headinsg should be listed
|
||||
# By default, only up to level three headings should be listed
|
||||
assert nwSplit.splitLevel.currentData() == 3
|
||||
assert nwSplit.listBox.count() == 11
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ KEY_DELAY = 1
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test initialising the editor.
|
||||
"""
|
||||
"""Test initialising the editor."""
|
||||
# Open project
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc)
|
||||
@@ -82,8 +81,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test loading text into the editor.
|
||||
"""
|
||||
"""Test loading text into the editor."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -137,8 +135,7 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test saving text from the editor.
|
||||
"""
|
||||
"""Test saving text from the editor."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -154,7 +151,7 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
||||
assert nwGUI.docEditor.saveText() is False
|
||||
nwGUI.docEditor._nwItem = nwItem
|
||||
|
||||
# Unkown handle
|
||||
# Unknown handle
|
||||
nwGUI.docEditor._docHandle = "0123456789abcdef"
|
||||
assert nwGUI.docEditor.saveText() is False
|
||||
nwGUI.docEditor._docHandle = C.hSceneDoc
|
||||
@@ -181,8 +178,7 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_MetaData(qtbot, nwGUI, projPath, mockRnd):
|
||||
"""Test extracting various meta data and other values.
|
||||
"""
|
||||
"""Test extracting various meta data and other values."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -461,8 +457,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test the document insert functions.
|
||||
"""
|
||||
"""Test the document insert functions."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -544,8 +539,7 @@ def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test the text manipulation functions.
|
||||
"""
|
||||
"""Test the text manipulation functions."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -751,8 +745,7 @@ def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, projPath, ipsumTex
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test the block formatting function.
|
||||
"""
|
||||
"""Test the block formatting function."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -1064,8 +1057,7 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test the document editor tags functionality.
|
||||
"""
|
||||
"""Test the document editor tags functionality."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
|
||||
@@ -1123,8 +1115,7 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||
"""Test saving text from the editor.
|
||||
"""
|
||||
"""Test saving text from the editor."""
|
||||
class MockThreadPool:
|
||||
|
||||
def __init__(self):
|
||||
@@ -1204,8 +1195,7 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, m
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
"""Test the document editor search functionality.
|
||||
"""
|
||||
"""Test the document editor search functionality."""
|
||||
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
|
||||
|
||||
assert nwGUI.openProject(prjLipsum) is True
|
||||
@@ -1413,8 +1403,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiEditor_StaticMethods():
|
||||
"""Test the document editor's static methods.
|
||||
"""
|
||||
"""Test the document editor's static methods."""
|
||||
# Check the method that decides if it is allowed to insert a space
|
||||
# before a colon using the French, Spanish, etc language feature
|
||||
assert GuiDocEditor._allowSpaceBeforeColon("", "") is True
|
||||
|
||||
@@ -34,8 +34,7 @@ from novelwriter.core.tohtml import ToHtml
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
"""Test the document viewer.
|
||||
"""
|
||||
"""Test the document viewer."""
|
||||
# Open project
|
||||
assert nwGUI.openProject(prjLipsum)
|
||||
|
||||
@@ -135,7 +134,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
||||
assert nwGUI.docViewer.docHeader.theTitle.text() == "Characters › Test Title"
|
||||
|
||||
# Ttile without full path
|
||||
# Title without full path
|
||||
CONFIG.showFullPath = False
|
||||
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
||||
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
|
||||
|
||||
@@ -94,6 +94,7 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
|
||||
# Block Formats
|
||||
# =============
|
||||
# cSpell:ignore Pellentesque erat nulla posuere commodo
|
||||
assert nwGUI.docEditor.setCursorPosition(42)
|
||||
|
||||
# Header 1
|
||||
|
||||
@@ -97,7 +97,7 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
assert novelTree.selectedItems()[0] == topItem
|
||||
assert novelView.getSelectedHandle() == (C.hTitlePage, "T0001")
|
||||
|
||||
# Refresh using the slot for the butoom
|
||||
# Refresh using the slot for the button
|
||||
novelBar._refreshNovelTree()
|
||||
assert novelTree.topLevelItem(0).isSelected()
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ def testGuiProjTree_PermanentlyDeleteItem(qtbot, caplog, monkeypatch, nwGUI, pro
|
||||
assert C.hTitlePage not in theProject.tree
|
||||
assert nwGUI.docEditor.docHandle() is None
|
||||
|
||||
# Deleting folder + files recursiely is ok
|
||||
# Deleting folder + files recursively is ok
|
||||
assert projTree.permanentlyDeleteItem(C.hChapterDir) is True
|
||||
assert C.hChapterDir not in theProject.tree
|
||||
assert C.hChapterDoc not in theProject.tree
|
||||
@@ -509,7 +509,7 @@ def testGuiProjTree_EmptyTrash(qtbot, caplog, monkeypatch, nwGUI, projPath, mock
|
||||
assert C.hChapterDoc not in theProject.tree
|
||||
assert C.hSceneDoc not in theProject.tree
|
||||
|
||||
# Running Emtpy Trash again is cancelled due to empty folder
|
||||
# Running Empty Trash again is cancelled due to empty folder
|
||||
assert projTree.emptyTrash() is False
|
||||
|
||||
nwGUI.closeProject()
|
||||
@@ -557,7 +557,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
# No item under menu
|
||||
assert projTree._openContextMenu(projTree.viewport().rect().bottomRight()) is False
|
||||
|
||||
# Generate the possible menu combinarions
|
||||
# Generate the possible menu combinations
|
||||
assert projTree._openContextMenu(itemPos(hTrashRoot)) is True
|
||||
assert projTree._openContextMenu(itemPos(C.hNovelRoot)) is True
|
||||
assert projTree._openContextMenu(itemPos(hNovelNote)) is True
|
||||
@@ -936,7 +936,7 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
# Send invalid handle
|
||||
assert projTree.revealNewTreeItem(C.hInvalid) is False
|
||||
|
||||
# Try to add an oprhaned file to the tree
|
||||
# Try to add an orphaned file to the tree
|
||||
nHandle = nwGUI.theProject.newFile("Test", C.hNovelRoot)
|
||||
nwGUI.theProject.tree[nHandle].setParent(None)
|
||||
assert projTree.revealNewTreeItem(nHandle) is False
|
||||
|
||||
@@ -349,7 +349,7 @@ def testGuiTheme_Icons(qtbot, caplog, monkeypatch, nwGUI, tstPaths):
|
||||
assert isinstance(qIcon, QIcon)
|
||||
assert qIcon.isNull() is True
|
||||
|
||||
# Load an icon, it is likelyu already cached
|
||||
# Load an icon, it is likely already cached
|
||||
qIcon = iconCache.getIcon("add")
|
||||
assert isinstance(qIcon, QIcon)
|
||||
assert qIcon.isNull() is False
|
||||
|
||||
@@ -151,7 +151,7 @@ def testManuscript_Builds(qtbot: QtBot, nwGUI: GuiMain, projPath: Path):
|
||||
|
||||
@pytest.mark.gui
|
||||
def testManuscript_Features(monkeypatch, qtbot: QtBot, nwGUI: GuiMain, projPath: Path):
|
||||
"""Test other featurs of the GuiManuscript dialog."""
|
||||
"""Test other features of the GuiManuscript dialog."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
nwGUI.openProject(projPath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user