Spell check comments and docstrings
This commit is contained in:
@@ -39,7 +39,7 @@ from novelwriter.config import Config
|
|||||||
# - Digit 1,2 : Major Version (01-ff)
|
# - Digit 1,2 : Major Version (01-ff)
|
||||||
# - Digit 3,4 : Minor Version (01-ff)
|
# - Digit 3,4 : Minor Version (01-ff)
|
||||||
# - Digit 5,6 : Patch Version (01-ff)
|
# - Digit 5,6 : Patch Version (01-ff)
|
||||||
# - Digit 7 : Release Type (a: aplha, b: beta, c: candidate, f: final)
|
# - Digit 7 : Release Type (a: alpha, b: beta, c: candidate, f: final)
|
||||||
# - Digit 8 : Release Number (0-f)
|
# - Digit 8 : Release Number (0-f)
|
||||||
#
|
#
|
||||||
# Example : Full Short Description
|
# Example : Full Short Description
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ def formatTime(t: int) -> str:
|
|||||||
|
|
||||||
def simplified(text: str) -> str:
|
def simplified(text: str) -> str:
|
||||||
"""Take a string and strip leading and trailing whitespaces, and
|
"""Take a string and strip leading and trailing whitespaces, and
|
||||||
replace all occurences of (multiple) whitespaces with a 0x20 space.
|
replace all occurrences of (multiple) whitespaces with a 0x20 space.
|
||||||
"""
|
"""
|
||||||
return " ".join(str(text).strip().split())
|
return " ".join(str(text).strip().split())
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class Config:
|
|||||||
# Size Settings
|
# Size Settings
|
||||||
self._mainWinSize = [1200, 650] # Last size of the main GUI window
|
self._mainWinSize = [1200, 650] # Last size of the main GUI window
|
||||||
self._prefsWinSize = [700, 615] # Last size of the Preferences dialog
|
self._prefsWinSize = [700, 615] # Last size of the Preferences dialog
|
||||||
self._projLoadCols = [280, 60, 160] # Last columns withs of the Project Load dialog
|
self._projLoadCols = [280, 60, 160] # Last columns widths of the Project Load dialog
|
||||||
self._mainPanePos = [300, 800] # Last position of the main window splitter
|
self._mainPanePos = [300, 800] # Last position of the main window splitter
|
||||||
self._viewPanePos = [500, 150] # Last position of the document viewer splitter
|
self._viewPanePos = [500, 150] # Last position of the document viewer splitter
|
||||||
self._outlnPanePos = [500, 150] # Last position of the outline panel splitter
|
self._outlnPanePos = [500, 150] # Last position of the outline panel splitter
|
||||||
@@ -135,7 +135,7 @@ class Config:
|
|||||||
self.autoSelect = True # Auto-select word when applying format with no selection
|
self.autoSelect = True # Auto-select word when applying format with no selection
|
||||||
|
|
||||||
self.doJustify = False # Justify text
|
self.doJustify = False # Justify text
|
||||||
self.showTabsNSpaces = False # Show tabs and spaces in edior
|
self.showTabsNSpaces = False # Show tabs and spaces in editor
|
||||||
self.showLineEndings = False # Show line endings in editor
|
self.showLineEndings = False # Show line endings in editor
|
||||||
self.showMultiSpaces = True # Highlight multiple spaces in the text
|
self.showMultiSpaces = True # Highlight multiple spaces in the text
|
||||||
|
|
||||||
@@ -781,7 +781,7 @@ class Config:
|
|||||||
return checkVal
|
return checkVal
|
||||||
|
|
||||||
def _checkOptionalPackages(self):
|
def _checkOptionalPackages(self):
|
||||||
"""Cheks if we have the optional packages used by some features.
|
"""Check if we have the optional packages used by some features.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
import enchant # noqa: F401
|
import enchant # noqa: F401
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ class nwConst:
|
|||||||
FMT_DSTAMP = "%Y-%m-%d" # Date only format
|
FMT_DSTAMP = "%Y-%m-%d" # Date only format
|
||||||
|
|
||||||
# Various Hard Limits
|
# Various Hard Limits
|
||||||
MAX_DOCSIZE = 5000000 # Maxium size of a single document
|
MAX_DOCSIZE = 5000000 # Maximum size of a single document
|
||||||
MAX_BUILDSIZE = 10000000 # Maxium size of a project build
|
MAX_BUILDSIZE = 10000000 # Maximum size of a project build
|
||||||
|
|
||||||
# URLs
|
# URLs
|
||||||
URL_WEB = "https://novelwriter.io"
|
URL_WEB = "https://novelwriter.io"
|
||||||
@@ -358,7 +358,7 @@ class nwUnicode:
|
|||||||
U_PERMIL = "\u2030" # Per mille sign
|
U_PERMIL = "\u2030" # Per mille sign
|
||||||
U_DEGREE = "\u00b0" # Degree symbol
|
U_DEGREE = "\u00b0" # Degree symbol
|
||||||
U_MINUS = "\u2212" # Minus sign
|
U_MINUS = "\u2212" # Minus sign
|
||||||
U_TIMES = "\u00d7" # Multiplaction sign
|
U_TIMES = "\u00d7" # Multiplication sign
|
||||||
U_DIVIDE = "\u00f7" # Division sign
|
U_DIVIDE = "\u00f7" # Division sign
|
||||||
|
|
||||||
# Arrows
|
# Arrows
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ class BuildCollection:
|
|||||||
return
|
return
|
||||||
|
|
||||||
def builds(self) -> Iterable[tuple[str, str]]:
|
def builds(self) -> Iterable[tuple[str, str]]:
|
||||||
"""Iterate over all avaiable builds."""
|
"""Iterate over all available builds."""
|
||||||
for buildID in self._builds:
|
for buildID in self._builds:
|
||||||
yield buildID, self._builds[buildID].get("name", "")
|
yield buildID, self._builds[buildID].get("name", "")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ class DocDuplicator:
|
|||||||
|
|
||||||
class ProjectBuilder:
|
class ProjectBuilder:
|
||||||
"""A class to build a new project from a set of user-defined
|
"""A class to build a new project from a set of user-defined
|
||||||
parameter provided by the New Projecty Wizard.
|
parameter provided by the New Project Wizard.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, mainGui: GuiMain) -> None:
|
def __init__(self, mainGui: GuiMain) -> None:
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class NWDocument:
|
|||||||
|
|
||||||
def readDocument(self, isOrphan: bool = False) -> str | None:
|
def readDocument(self, isOrphan: bool = False) -> str | None:
|
||||||
"""Read the document specified by the handle set in the
|
"""Read the document specified by the handle set in the
|
||||||
contructor, capturing potential file system errors and parse
|
constructor, capturing potential file system errors and parse
|
||||||
meta data. If the document doesn't exist on disk, return an
|
meta data. If the document doesn't exist on disk, return an
|
||||||
empty string. If something went wrong, return None.
|
empty string. If something went wrong, return None.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ class TagsIndex:
|
|||||||
class ItemIndex:
|
class ItemIndex:
|
||||||
"""Core: Item Index Wrapper Class
|
"""Core: Item Index Wrapper Class
|
||||||
|
|
||||||
A wrapper object holding the indexed items. This is a warapper
|
A wrapper object holding the indexed items. This is a wrapper
|
||||||
class around a single storage dictionary with a set of utility
|
class around a single storage dictionary with a set of utility
|
||||||
functions for setting and accessing the index data. Each indexed
|
functions for setting and accessing the index data. Each indexed
|
||||||
item is stored in an IndexItem object, which again holds an
|
item is stored in an IndexItem object, which again holds an
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class NWProject(QObject):
|
|||||||
self._storage = NWStorage(self) # The project storage handler
|
self._storage = NWStorage(self) # The project storage handler
|
||||||
self._data = NWProjectData(self) # The project settings
|
self._data = NWProjectData(self) # The project settings
|
||||||
self._tree = NWTree(self) # The project tree
|
self._tree = NWTree(self) # The project tree
|
||||||
self._index = NWIndex(self) # The projecty index
|
self._index = NWIndex(self) # The project index
|
||||||
self._session = NWSessionLog(self) # The session record
|
self._session = NWSessionLog(self) # The session record
|
||||||
|
|
||||||
# Data Cache
|
# Data Cache
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class NWProjectData:
|
|||||||
return
|
return
|
||||||
|
|
||||||
def setEditTime(self, value: Any):
|
def setEditTime(self, value: Any):
|
||||||
"""Set tyje edit time from last session."""
|
"""Set the edit time from last session."""
|
||||||
self._editTime = checkInt(value, 0)
|
self._editTime = checkInt(value, 0)
|
||||||
self.theProject.setProjectChanged(True)
|
self.theProject.setProjectChanged(True)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ class ProjectXMLReader:
|
|||||||
|
|
||||||
1.4 Introduces a more compact format for storing items. All settings
|
1.4 Introduces a more compact format for storing items. All settings
|
||||||
aside from name are now attributes. This format also changes the
|
aside from name are now attributes. This format also changes the
|
||||||
way satus and importance labels are stored. This format was only
|
way status and importance labels are stored. This format was only
|
||||||
a part of version 2.0 RC 1
|
a part of version 2.0 RC 1
|
||||||
|
|
||||||
1.5 The actual format released for 2.0. It moves last used handles
|
1.5 The actual format released for 2.0. It moves last used handles
|
||||||
and title formats into a key/value format similar to auto-
|
and title formats into a key/value format similar to auto-
|
||||||
replace, status and imporetance. It adds the heading value to
|
replace, status and importance. It adds the heading value to
|
||||||
the content item meta entry. It also moves meta data related to
|
the content item meta entry. It also moves meta data related to
|
||||||
the project or the content into their respective section nodes
|
the project or the content into their respective section nodes
|
||||||
as attributes. The id attribute was also added to the project.
|
as attributes. The id attribute was also added to the project.
|
||||||
@@ -452,7 +452,7 @@ class ProjectXMLReader:
|
|||||||
|
|
||||||
def _parseDictKeyText(self, xItem: ET.Element) -> dict:
|
def _parseDictKeyText(self, xItem: ET.Element) -> dict:
|
||||||
"""Parse a dictionary stored with key as an attribute and the
|
"""Parse a dictionary stored with key as an attribute and the
|
||||||
value as the text porperty.
|
value as the text property.
|
||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
for xEntry in xItem:
|
for xEntry in xItem:
|
||||||
@@ -462,7 +462,7 @@ class ProjectXMLReader:
|
|||||||
|
|
||||||
def _parseDictTagText(self, xItem):
|
def _parseDictTagText(self, xItem):
|
||||||
"""Parse a dictionary stored with key as the tag and the value
|
"""Parse a dictionary stored with key as the tag and the value
|
||||||
as the text porperty.
|
as the text property.
|
||||||
"""
|
"""
|
||||||
return {xNode.tag: checkString(xNode.text, "") for xNode in xItem}
|
return {xNode.tag: checkString(xNode.text, "") for xNode in xItem}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class NWSessionLog:
|
|||||||
##
|
##
|
||||||
|
|
||||||
def startSession(self):
|
def startSession(self):
|
||||||
"""Start the writng session."""
|
"""Start the writing session."""
|
||||||
self._start = time()
|
self._start = time()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class NWStorage:
|
|||||||
"""
|
"""
|
||||||
inPath = Path(path).resolve()
|
inPath = Path(path).resolve()
|
||||||
if inPath.is_file():
|
if inPath.is_file():
|
||||||
# The path should not point to an exisitng file,
|
# The path should not point to an existing file,
|
||||||
# but it can point to a folder containing files
|
# but it can point to a folder containing files
|
||||||
inPath = inPath.parent
|
inPath = inPath.parent
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ class NWStorage:
|
|||||||
if not checkLegacy:
|
if not checkLegacy:
|
||||||
# The legacy content check is only needed for project folder
|
# The legacy content check is only needed for project folder
|
||||||
# storage, so if it is not expected to be that, there's no
|
# storage, so if it is not expected to be that, there's no
|
||||||
# need for the remaning checks.
|
# need for the remaining checks.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
legacy = _LegacyStorage(self._project)
|
legacy = _LegacyStorage(self._project)
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class ToOdt(Tokenizer):
|
|||||||
self._dLanguage = "en"
|
self._dLanguage = "en"
|
||||||
self._dCountry = "GB"
|
self._dCountry = "GB"
|
||||||
|
|
||||||
# Text Margings
|
# Text Margins
|
||||||
self._mTopTitle = "0.423cm"
|
self._mTopTitle = "0.423cm"
|
||||||
self._mTopHead1 = "0.423cm"
|
self._mTopHead1 = "0.423cm"
|
||||||
self._mTopHead2 = "0.353cm"
|
self._mTopHead2 = "0.353cm"
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class NWTree:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def pack(self) -> list[dict]:
|
def pack(self) -> list[dict]:
|
||||||
"""Pack the content of the tree into a list of doctionaries of
|
"""Pack the content of the tree into a list of dictionaries of
|
||||||
items. In the order defined by the _treeOrder list.
|
items. In the order defined by the _treeOrder list.
|
||||||
"""
|
"""
|
||||||
tree = []
|
tree = []
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class NSwitchBox(QScrollArea):
|
|||||||
|
|
||||||
def _bumpIndex(self):
|
def _bumpIndex(self):
|
||||||
"""Increase the index counter and make sure only the last
|
"""Increase the index counter and make sure only the last
|
||||||
columns is stretcing.
|
columns is stretching.
|
||||||
"""
|
"""
|
||||||
self._content.setRowStretch(self._index, 0)
|
self._content.setRowStretch(self._index, 0)
|
||||||
self._content.setRowStretch(self._index + 1, 1)
|
self._content.setRowStretch(self._index + 1, 1)
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.setDocumentChanged(False)
|
self.setDocumentChanged(False)
|
||||||
qApp.restoreOverrideCursor()
|
qApp.restoreOverrideCursor()
|
||||||
|
|
||||||
# This is a hack to fix invisble cursor on an empty document
|
# This is a hack to fix invisible cursor on an empty document
|
||||||
if self.document().characterCount() <= 1:
|
if self.document().characterCount() <= 1:
|
||||||
self.setPlainText("\n")
|
self.setPlainText("\n")
|
||||||
self.setPlainText("")
|
self.setPlainText("")
|
||||||
@@ -1001,7 +1001,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
We need to intercept a few key sequences:
|
We need to intercept a few key sequences:
|
||||||
* The return and enter keys redirect here even if the search
|
* The return and enter keys redirect here even if the search
|
||||||
box has focus. Since we need these keys to continue search,
|
box has focus. Since we need these keys to continue search,
|
||||||
we block any further interaction here while ithas focus.
|
we block any further interaction here while it has focus.
|
||||||
* The undo/redo/select all sequences bypass the docAction
|
* The undo/redo/select all sequences bypass the docAction
|
||||||
pathway from the menu, so we redirect them back from here.
|
pathway from the menu, so we redirect them back from here.
|
||||||
* We also handle automatic scrolling here.
|
* We also handle automatic scrolling here.
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
def initHighlighter(self):
|
def initHighlighter(self):
|
||||||
"""Initialise the syntax highlighter, setting all the colour
|
"""Initialise the syntax highlighter, setting all the colour
|
||||||
rules and building the regexes.
|
rules and building the RegExes.
|
||||||
"""
|
"""
|
||||||
logger.debug("Setting up highlighting rules")
|
logger.debug("Setting up highlighting rules")
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
##
|
##
|
||||||
|
|
||||||
def rehighlightByType(self, theType):
|
def rehighlightByType(self, theType):
|
||||||
"""Loop through all blocks and rehighlight those of a given
|
"""Loop through all blocks and re-highlight those of a given
|
||||||
content type.
|
content type.
|
||||||
"""
|
"""
|
||||||
qDoc = self.document()
|
qDoc = self.document()
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
theCursor.select(selMode)
|
theCursor.select(selMode)
|
||||||
|
|
||||||
if selMode == QTextCursor.BlockUnderCursor:
|
if selMode == QTextCursor.BlockUnderCursor:
|
||||||
# This selection mode also selects the preceding oaragraph
|
# This selection mode also selects the preceding paragraph
|
||||||
# separator, which we want to avoid.
|
# separator, which we want to avoid.
|
||||||
posS = theCursor.selectionStart()
|
posS = theCursor.selectionStart()
|
||||||
posE = theCursor.selectionEnd()
|
posE = theCursor.selectionEnd()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
novelWriter – GUI Novel Tree
|
novelWriter – GUI Novel Tree
|
||||||
============================
|
============================
|
||||||
GUI classe for the main window novel tree
|
GUI class for the main window novel tree
|
||||||
|
|
||||||
File History:
|
File History:
|
||||||
Created: 2020-12-20 [1.1rc1] GuiNovelTree
|
Created: 2020-12-20 [1.1rc1] GuiNovelTree
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ class GuiOutlineToolBar(QToolBar):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def populateNovelList(self):
|
def populateNovelList(self):
|
||||||
"""Relaod the content of the novel list.
|
"""Reload the content of the novel list.
|
||||||
"""
|
"""
|
||||||
self.novelValue.updateList(includeAll=True)
|
self.novelValue.updateList(includeAll=True)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ class GuiProjectToolBar(QWidget):
|
|||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def _treeSelectionChanged(self, tHandle):
|
def _treeSelectionChanged(self, tHandle):
|
||||||
"""Toggle the visibility of the new item enties for novel
|
"""Toggle the visibility of the new item entries for novel
|
||||||
documents. They should only be visible if novel documents can
|
documents. They should only be visible if novel documents can
|
||||||
actually be added.
|
actually be added.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ class GuiManuscript(QDialog):
|
|||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
"""Capture the user closing the window so we can save GUI
|
"""Capture the user closing the window so we can save GUI
|
||||||
settings. We also check that we don't have a build settings
|
settings. We also check that we don't have a build settings
|
||||||
diralog open.
|
dialog open.
|
||||||
"""
|
"""
|
||||||
self._saveSettings()
|
self._saveSettings()
|
||||||
for obj in self.children():
|
for obj in self.children():
|
||||||
@@ -430,7 +430,7 @@ class GuiManuscript(QDialog):
|
|||||||
bItem = self._buildMap.get(build.buildID, None)
|
bItem = self._buildMap.get(build.buildID, None)
|
||||||
if isinstance(bItem, QListWidgetItem):
|
if isinstance(bItem, QListWidgetItem):
|
||||||
bItem.setText(build.name)
|
bItem.setText(build.name)
|
||||||
else: # Propbably a new item
|
else: # Probably a new item
|
||||||
self._updateBuildsList()
|
self._updateBuildsList()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ def testBaseCommon_CheckBool():
|
|||||||
assert checkBool(0, True) is False
|
assert checkBool(0, True) is False
|
||||||
assert checkBool(1, False) is True
|
assert checkBool(1, False) is True
|
||||||
|
|
||||||
# Inalid Integers
|
# Invalid Integers
|
||||||
assert checkBool(2, True) is True
|
assert checkBool(2, True) is True
|
||||||
assert checkBool(2, False) is False
|
assert checkBool(2, False) is False
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ from novelwriter.constants import nwFiles
|
|||||||
|
|
||||||
@pytest.mark.base
|
@pytest.mark.base
|
||||||
def testBaseConfig_Constructor(monkeypatch):
|
def testBaseConfig_Constructor(monkeypatch):
|
||||||
"""Test config contructor.
|
"""Test config constructor."""
|
||||||
"""
|
|
||||||
# Linux
|
# Linux
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr("sys.platform", "linux")
|
mp.setattr("sys.platform", "linux")
|
||||||
@@ -93,8 +92,7 @@ def testBaseConfig_Constructor(monkeypatch):
|
|||||||
|
|
||||||
@pytest.mark.base
|
@pytest.mark.base
|
||||||
def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths):
|
def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths):
|
||||||
"""Test config intialisation.
|
"""Test config initialisation."""
|
||||||
"""
|
|
||||||
tstConf = Config()
|
tstConf = Config()
|
||||||
|
|
||||||
confFile = fncPath / nwFiles.CONF_FILE
|
confFile = fncPath / nwFiles.CONF_FILE
|
||||||
@@ -159,8 +157,7 @@ def testBaseConfig_InitLoadSave(monkeypatch, fncPath, tstPaths):
|
|||||||
|
|
||||||
@pytest.mark.base
|
@pytest.mark.base
|
||||||
def testBaseConfig_Localisation(fncPath, tstPaths):
|
def testBaseConfig_Localisation(fncPath, tstPaths):
|
||||||
"""Test localisation.
|
"""Test localisation."""
|
||||||
"""
|
|
||||||
tstConf = Config()
|
tstConf = Config()
|
||||||
tstConf.initConfig(confPath=fncPath, dataPath=fncPath)
|
tstConf.initConfig(confPath=fncPath, dataPath=fncPath)
|
||||||
|
|
||||||
@@ -198,8 +195,7 @@ def testBaseConfig_Localisation(fncPath, tstPaths):
|
|||||||
|
|
||||||
@pytest.mark.base
|
@pytest.mark.base
|
||||||
def testBaseConfig_Methods(fncPath):
|
def testBaseConfig_Methods(fncPath):
|
||||||
"""Check class methods.
|
"""Check class methods."""
|
||||||
"""
|
|
||||||
tstConf = Config()
|
tstConf = Config()
|
||||||
tstConf.initConfig(confPath=fncPath, dataPath=fncPath)
|
tstConf.initConfig(confPath=fncPath, dataPath=fncPath)
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ def testBaseError_Dialog(qtbot, monkeypatch, nwGUI):
|
|||||||
def testBaseError_Handler(qtbot, monkeypatch, nwGUI):
|
def testBaseError_Handler(qtbot, monkeypatch, nwGUI):
|
||||||
"""Test the error handler. This test doesn'thave any asserts, but it
|
"""Test the error handler. This test doesn'thave any asserts, but it
|
||||||
checks that the error handler handles potential exceptions. The test
|
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
|
# Normal shutdown
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
|
|||||||
@@ -387,12 +387,12 @@ def testCoreBuildSettings_Collection(monkeypatch, mockGUI, fncPath: Path, mockRn
|
|||||||
assert len(builds) == 0
|
assert len(builds) == 0
|
||||||
assert not buildsFile.exists()
|
assert not buildsFile.exists()
|
||||||
|
|
||||||
# Greate a default build
|
# Create a default build
|
||||||
buildOne = BuildSettings()
|
buildOne = BuildSettings()
|
||||||
buildOne.setName("Build One")
|
buildOne.setName("Build One")
|
||||||
buildIDOne = buildOne.buildID
|
buildIDOne = buildOne.buildID
|
||||||
|
|
||||||
# Check that invalid type is ahndled
|
# Check that invalid type is handled
|
||||||
builds.setBuild(None) # type: ignore
|
builds.setBuild(None) # type: ignore
|
||||||
assert len(builds) == 0
|
assert len(builds) == 0
|
||||||
assert not buildsFile.exists()
|
assert not buildsFile.exists()
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ BUILD_CONF = {
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
||||||
"""Test builing an open document manuscript."""
|
"""Test building an open document manuscript."""
|
||||||
project = NWProject(mockGUI)
|
project = NWProject(mockGUI)
|
||||||
project.openProject(prjLipsum)
|
project.openProject(prjLipsum)
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstP
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
||||||
"""Test builing an HTML manuscript."""
|
"""Test building an HTML manuscript."""
|
||||||
project = NWProject(mockGUI)
|
project = NWProject(mockGUI)
|
||||||
project.openProject(prjLipsum)
|
project.openProject(prjLipsum)
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
||||||
"""Test builing an Markdown manuscript."""
|
"""Test building an Markdown manuscript."""
|
||||||
project = NWProject(mockGUI)
|
project = NWProject(mockGUI)
|
||||||
project.openProject(prjLipsum)
|
project.openProject(prjLipsum)
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
||||||
"""Test builing a NWD manuscript."""
|
"""Test building a NWD manuscript."""
|
||||||
project = NWProject(mockGUI)
|
project = NWProject(mockGUI)
|
||||||
project.openProject(prjLipsum)
|
project.openProject(prjLipsum)
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ from novelwriter.core.project import NWProject
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreIndex_LoadSave(monkeypatch, prjLipsum, mockGUI, tstPaths):
|
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.
|
the index cache file.
|
||||||
"""
|
"""
|
||||||
projFile = prjLipsum / "meta" / nwFiles.INDEX_FILE
|
projFile = prjLipsum / "meta" / nwFiles.INDEX_FILE
|
||||||
@@ -154,8 +154,7 @@ def testCoreIndex_LoadSave(monkeypatch, prjLipsum, mockGUI, tstPaths):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreIndex_ScanThis(mockGUI):
|
def testCoreIndex_ScanThis(mockGUI):
|
||||||
"""Test the tag scanner function scanThis.
|
"""Test the tag scanner function scanThis."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theIndex = theProject.index
|
theIndex = theProject.index
|
||||||
|
|
||||||
@@ -281,8 +280,7 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreIndex_ScanText(mockGUI, fncPath, mockRnd):
|
def testCoreIndex_ScanText(mockGUI, fncPath, mockRnd):
|
||||||
"""Check the index text scanner.
|
"""Check the index text scanner."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(theProject, fncPath)
|
buildTestProject(theProject, fncPath)
|
||||||
@@ -503,8 +501,7 @@ def testCoreIndex_ScanText(mockGUI, fncPath, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
||||||
"""Check the index data extraction functions.
|
"""Check the index data extraction functions."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(theProject, fncPath)
|
buildTestProject(theProject, fncPath)
|
||||||
@@ -591,7 +588,7 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
|||||||
# getReferences
|
# getReferences
|
||||||
# =============
|
# =============
|
||||||
|
|
||||||
# Look up an ivalid handle
|
# Look up an invalid handle
|
||||||
theRefs = theIndex.getReferences("Not a handle")
|
theRefs = theIndex.getReferences("Not a handle")
|
||||||
assert theRefs["@pov"] == []
|
assert theRefs["@pov"] == []
|
||||||
assert theRefs["@char"] == []
|
assert theRefs["@char"] == []
|
||||||
@@ -784,8 +781,7 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreIndex_TagsIndex():
|
def testCoreIndex_TagsIndex():
|
||||||
"""Check the TagsIndex class.
|
"""Check the TagsIndex class."""
|
||||||
"""
|
|
||||||
tagsIndex = TagsIndex()
|
tagsIndex = TagsIndex()
|
||||||
assert tagsIndex._tags == {}
|
assert tagsIndex._tags == {}
|
||||||
|
|
||||||
@@ -847,7 +843,7 @@ def testCoreIndex_TagsIndex():
|
|||||||
# Pack Data
|
# Pack Data
|
||||||
assert tagsIndex.packData() == content
|
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["Tag2"]
|
||||||
del tagsIndex["Tag4"]
|
del tagsIndex["Tag4"]
|
||||||
assert "Tag1" in tagsIndex
|
assert "Tag1" in tagsIndex
|
||||||
@@ -944,8 +940,7 @@ def testCoreIndex_TagsIndex():
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
|
def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
|
||||||
"""Check the ItemIndex class.
|
"""Check the ItemIndex class."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(theProject, fncPath)
|
buildTestProject(theProject, fncPath)
|
||||||
@@ -981,7 +976,7 @@ def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
|
|||||||
# Add a heading to an invalid item
|
# Add a heading to an invalid item
|
||||||
assert itemIndex.addItemHeading(C.hInvalid, 1, "H1", "Stuff") == "T0000"
|
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.setHeadingCounts(cHandle, "T0001", 60, 10, 2)
|
||||||
itemIndex.setHeadingSynopsis(cHandle, "T0001", "In the beginning ...")
|
itemIndex.setHeadingSynopsis(cHandle, "T0001", "In the beginning ...")
|
||||||
itemIndex.setHeadingTag(cHandle, "T0001", "One")
|
itemIndex.setHeadingTag(cHandle, "T0001", "One")
|
||||||
@@ -1183,8 +1178,7 @@ def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreIndex_CountWords():
|
def testCoreIndex_CountWords():
|
||||||
"""Test the word counter and the exclusion filers.
|
"""Test the word counter and the exclusion filers."""
|
||||||
"""
|
|
||||||
# Non-Text
|
# Non-Text
|
||||||
assert countWords(None) == (0, 0, 0)
|
assert countWords(None) == (0, 0, 0)
|
||||||
assert countWords(1234) == (0, 0, 0)
|
assert countWords(1234) == (0, 0, 0)
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLR
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreProject_NewRoot(fncPath, tstPaths, mockGUI, mockRnd):
|
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"
|
projFile = fncPath / "nwProject.nwx"
|
||||||
testFile = tstPaths.outDir / "coreProject_NewRoot_nwProject.nwx"
|
testFile = tstPaths.outDir / "coreProject_NewRoot_nwProject.nwx"
|
||||||
compFile = tstPaths.refDir / "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
|
@pytest.mark.core
|
||||||
def testCoreProject_NewFileFolder(monkeypatch, fncPath, tstPaths, mockGUI, mockRnd):
|
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"
|
projFile = fncPath / "nwProject.nwx"
|
||||||
testFile = tstPaths.outDir / "coreProject_NewFileFolder_nwProject.nwx"
|
testFile = tstPaths.outDir / "coreProject_NewFileFolder_nwProject.nwx"
|
||||||
compFile = tstPaths.refDir / "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
|
@pytest.mark.core
|
||||||
def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd):
|
def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd):
|
||||||
"""Test opening a project.
|
"""Test opening a project."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(theProject, fncPath)
|
buildTestProject(theProject, fncPath)
|
||||||
@@ -259,8 +256,7 @@ def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath):
|
def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath):
|
||||||
"""Test saving a project.
|
"""Test saving a project."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
|
|
||||||
# Nothing to save
|
# Nothing to save
|
||||||
@@ -289,8 +285,7 @@ def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd):
|
def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd):
|
||||||
"""Test helper functions for the project folder.
|
"""Test helper functions for the project folder."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
buildTestProject(theProject, fncPath)
|
buildTestProject(theProject, fncPath)
|
||||||
|
|
||||||
@@ -354,8 +349,7 @@ def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreProject_StatusImport(mockGUI, fncPath, mockRnd):
|
def testCoreProject_StatusImport(mockGUI, fncPath, mockRnd):
|
||||||
"""Test the status and importance flag handling.
|
"""Test the status and importance flag handling."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(theProject, fncPath)
|
buildTestProject(theProject, fncPath)
|
||||||
@@ -506,7 +500,7 @@ def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd):
|
|||||||
assert theProject.data.spellLang is None
|
assert theProject.data.spellLang is None
|
||||||
theProject.data.setSpellLang(None)
|
theProject.data.setSpellLang(None)
|
||||||
assert theProject.data.spellLang is 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
|
assert theProject.data.spellLang is None
|
||||||
theProject.data.setSpellLang("en_GB")
|
theProject.data.setSpellLang("en_GB")
|
||||||
assert theProject.data.spellLang == "en_GB"
|
assert theProject.data.spellLang == "en_GB"
|
||||||
@@ -589,7 +583,7 @@ def testCoreProject_OrphanedFiles(mockGUI, prjLipsum):
|
|||||||
assert theProject.tree["636b6aa9b697b"] is None
|
assert theProject.tree["636b6aa9b697b"] is None
|
||||||
|
|
||||||
# Add a file with non-existent parent
|
# 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")
|
oHandle = theProject.newFile("Oops", "b3643d0f92e32")
|
||||||
theProject.tree[oHandle].setParent("1234567890abc")
|
theProject.tree[oHandle].setParent("1234567890abc")
|
||||||
|
|
||||||
@@ -663,7 +657,7 @@ def testCoreProject_OrphanedFiles(mockGUI, prjLipsum):
|
|||||||
def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths):
|
def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths):
|
||||||
"""Test the automated backup feature of the project class. The test
|
"""Test the automated backup feature of the project class. The test
|
||||||
creates a backup of the Minimal test project, and then unzips the
|
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.
|
the original file.
|
||||||
"""
|
"""
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
|
|||||||
assert xmlReader.read(data, content) is False
|
assert xmlReader.read(data, content) is False
|
||||||
assert xmlReader.state == XMLReadState.UNKNOWN_VERSION
|
assert xmlReader.state == XMLReadState.UNKNOWN_VERSION
|
||||||
|
|
||||||
# Check parsing of unkown sections
|
# Check parsing of unknown sections
|
||||||
writeFile(xmlFile, (
|
writeFile(xmlFile, (
|
||||||
"<novelWriterXML fileVersion='1.5'>"
|
"<novelWriterXML fileVersion='1.5'>"
|
||||||
" <project>"
|
" <project>"
|
||||||
@@ -243,8 +243,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
|
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"
|
refFile = tstPaths.filesDir / "nwProject-1.0.nwx"
|
||||||
xmlFile = fncPath / "nwProject-1.0.nwx"
|
xmlFile = fncPath / "nwProject-1.0.nwx"
|
||||||
outFile = fncPath / "nwProject.nwx"
|
outFile = fncPath / "nwProject.nwx"
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ def testCoreSessions_Main(monkeypatch, mockGUI, fncPath):
|
|||||||
logFile = project.storage.getMetaFile(nwFiles.SESS_FILE)
|
logFile = project.storage.getMetaFile(nwFiles.SESS_FILE)
|
||||||
assert isinstance(logFile, Path)
|
assert isinstance(logFile, Path)
|
||||||
|
|
||||||
# Set some moch word counts
|
# Set some mock word counts
|
||||||
project.data.setInitCounts(50, 60)
|
project.data.setInitCounts(50, 60)
|
||||||
project.data.setCurrCounts(160, 150)
|
project.data.setCurrCounts(160, 150)
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ class BareTokenizer(Tokenizer):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_Setters(mockGUI):
|
def testCoreToken_Setters(mockGUI):
|
||||||
"""Test all the setters for the Tokenizer class.
|
"""Test all the setters for the Tokenizer class."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theToken = BareTokenizer(theProject)
|
theToken = BareTokenizer(theProject)
|
||||||
|
|
||||||
@@ -133,8 +132,7 @@ def testCoreToken_Setters(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
mockRnd.reset()
|
mockRnd.reset()
|
||||||
buildTestProject(theProject, fncPath)
|
buildTestProject(theProject, fncPath)
|
||||||
@@ -212,7 +210,7 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
|
|||||||
"# Notes: Plot\n\n"
|
"# Notes: Plot\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ckeck abstract method
|
# Check abstract method
|
||||||
with pytest.raises(NotImplementedError):
|
with pytest.raises(NotImplementedError):
|
||||||
theToken.doConvert()
|
theToken.doConvert()
|
||||||
|
|
||||||
@@ -221,8 +219,7 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_StripEscape():
|
def testCoreToken_StripEscape():
|
||||||
"""Test the stripEscape helper function.
|
"""Test the stripEscape helper function."""
|
||||||
"""
|
|
||||||
text1 = "This is text with escapes: \\** \\~~ \\__"
|
text1 = "This is text with escapes: \\** \\~~ \\__"
|
||||||
text2 = "This is text with escapes: ** ~~ __"
|
text2 = "This is text with escapes: ** ~~ __"
|
||||||
assert stripEscape(text1) == "This is text with escapes: ** ~~ __"
|
assert stripEscape(text1) == "This is text with escapes: ** ~~ __"
|
||||||
@@ -233,8 +230,7 @@ def testCoreToken_StripEscape():
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_HeaderFormat(mockGUI):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
theToken = BareTokenizer(theProject)
|
theToken = BareTokenizer(theProject)
|
||||||
theToken.setKeepMarkdown(True)
|
theToken.setKeepMarkdown(True)
|
||||||
@@ -437,8 +433,7 @@ def testCoreToken_HeaderFormat(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_MetaFormat(mockGUI):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
theToken = BareTokenizer(theProject)
|
theToken = BareTokenizer(theProject)
|
||||||
theToken.setKeepMarkdown(True)
|
theToken.setKeepMarkdown(True)
|
||||||
@@ -456,7 +451,7 @@ def testCoreToken_MetaFormat(mockGUI):
|
|||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
assert theToken.theMarkdown[-1] == "% A comment\n\n"
|
assert theToken.theMarkdown[-1] == "% A comment\n\n"
|
||||||
|
|
||||||
# Symopsis
|
# Synopsis
|
||||||
theToken._text = "%synopsis: The synopsis\n"
|
theToken._text = "%synopsis: The synopsis\n"
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
assert theToken._tokens == [
|
assert theToken._tokens == [
|
||||||
@@ -506,8 +501,7 @@ def testCoreToken_MetaFormat(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_MarginFormat(mockGUI):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
theToken = BareTokenizer(theProject)
|
theToken = BareTokenizer(theProject)
|
||||||
theToken.setKeepMarkdown(True)
|
theToken.setKeepMarkdown(True)
|
||||||
@@ -561,8 +555,7 @@ def testCoreToken_MarginFormat(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_TextFormat(mockGUI):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
theToken = BareTokenizer(theProject)
|
theToken = BareTokenizer(theProject)
|
||||||
theToken.setKeepMarkdown(True)
|
theToken.setKeepMarkdown(True)
|
||||||
@@ -683,8 +676,7 @@ def testCoreToken_TextFormat(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_SpecialFormat(mockGUI):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
theToken = BareTokenizer(theProject)
|
theToken = BareTokenizer(theProject)
|
||||||
|
|
||||||
@@ -886,8 +878,7 @@ def testCoreToken_SpecialFormat(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToken_ProcessHeaders(mockGUI):
|
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 = NWProject(mockGUI)
|
||||||
theProject.data.setLanguage("en")
|
theProject.data.setLanguage("en")
|
||||||
theProject._loadProjectLocalisation()
|
theProject._loadProjectLocalisation()
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ from novelwriter.core.project import NWProject
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToMarkdown_ConvertFormat(mockGUI):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
theMD = ToMarkdown(theProject)
|
theMD = ToMarkdown(theProject)
|
||||||
@@ -157,8 +158,7 @@ def testCoreToMarkdown_ConvertFormat(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToMarkdown_ConvertDirect(mockGUI):
|
def testCoreToMarkdown_ConvertDirect(mockGUI):
|
||||||
"""Test the converter directly using the ToMarkdown class.
|
"""Test the converter directly using the ToMarkdown class."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theMD = ToMarkdown(theProject)
|
theMD = ToMarkdown(theProject)
|
||||||
|
|
||||||
@@ -208,8 +208,7 @@ def testCoreToMarkdown_ConvertDirect(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToMarkdown_Complex(mockGUI, fncPath):
|
def testCoreToMarkdown_Complex(mockGUI, fncPath):
|
||||||
"""Test the save method of the ToMarkdown class.
|
"""Test the save method of the ToMarkdown class."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theMD = ToMarkdown(theProject)
|
theMD = ToMarkdown(theProject)
|
||||||
theMD._isNovel = True
|
theMD._isNovel = True
|
||||||
@@ -261,8 +260,7 @@ def testCoreToMarkdown_Complex(mockGUI, fncPath):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreToMarkdown_Format(mockGUI):
|
def testCoreToMarkdown_Format(mockGUI):
|
||||||
"""Test all the formatters for the ToMarkdown class.
|
"""Test all the formatters for the ToMarkdown class."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theMD = ToMarkdown(theProject)
|
theMD = ToMarkdown(theProject)
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ from novelwriter.core.project import NWProject
|
|||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def mockItems(mockGUI, mockRnd):
|
def mockItems(mockGUI, mockRnd):
|
||||||
"""Create a list of mock items.
|
"""Create a list of mock items."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
|
|
||||||
itemA = NWItem(theProject)
|
itemA = NWItem(theProject)
|
||||||
@@ -113,8 +112,7 @@ def mockItems(mockGUI, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreTree_BuildTree(mockGUI, mockItems):
|
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)
|
theProject = NWProject(mockGUI)
|
||||||
theTree = NWTree(theProject)
|
theTree = NWTree(theProject)
|
||||||
|
|
||||||
@@ -232,8 +230,7 @@ def testCoreTree_BuildTree(mockGUI, mockItems):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreTree_PackUnpack(mockGUI, mockItems):
|
def testCoreTree_PackUnpack(mockGUI, mockItems):
|
||||||
"""Test packing and unpacking data.
|
"""Test packing and unpacking data."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theTree = NWTree(theProject)
|
theTree = NWTree(theProject)
|
||||||
|
|
||||||
@@ -262,8 +259,7 @@ def testCoreTree_PackUnpack(mockGUI, mockItems):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreTree_Methods(mockGUI, mockItems):
|
def testCoreTree_Methods(mockGUI, mockItems):
|
||||||
"""Test various class methods.
|
"""Test various class methods."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theTree = NWTree(theProject)
|
theTree = NWTree(theProject)
|
||||||
|
|
||||||
@@ -343,8 +339,7 @@ def testCoreTree_Methods(mockGUI, mockItems):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreTree_MakeHandles(mockGUI):
|
def testCoreTree_MakeHandles(mockGUI):
|
||||||
"""Test generating item handles.
|
"""Test generating item handles."""
|
||||||
"""
|
|
||||||
random.seed(42)
|
random.seed(42)
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theTree = NWTree(theProject)
|
theTree = NWTree(theProject)
|
||||||
@@ -373,8 +368,7 @@ def testCoreTree_MakeHandles(mockGUI):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreTree_Stats(mockGUI, mockItems):
|
def testCoreTree_Stats(mockGUI, mockItems):
|
||||||
"""Test project stats methods.
|
"""Test project stats methods."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theTree = NWTree(theProject)
|
theTree = NWTree(theProject)
|
||||||
|
|
||||||
@@ -394,8 +388,7 @@ def testCoreTree_Stats(mockGUI, mockItems):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreTree_Reorder(caplog, mockGUI, mockItems):
|
def testCoreTree_Reorder(caplog, mockGUI, mockItems):
|
||||||
"""Test changing tree order.
|
"""Test changing tree order."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theTree = NWTree(theProject)
|
theTree = NWTree(theProject)
|
||||||
|
|
||||||
@@ -430,8 +423,7 @@ def testCoreTree_Reorder(caplog, mockGUI, mockItems):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreTree_ToCFile(monkeypatch, tstPaths, mockGUI, mockItems):
|
def testCoreTree_ToCFile(monkeypatch, tstPaths, mockGUI, mockItems):
|
||||||
"""Test writing the ToC.txt file.
|
"""Test writing the ToC.txt file."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theTree = NWTree(theProject)
|
theTree = NWTree(theProject)
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ from novelwriter.dialogs.about import GuiAbout
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
||||||
"""Test the novelWriter about dialogs.
|
"""Test the novelWriter about dialogs."""
|
||||||
"""
|
|
||||||
# NW About
|
# NW About
|
||||||
nwGUI.mainTheme.themeName = "A Theme"
|
nwGUI.mainTheme.themeName = "A Theme"
|
||||||
nwGUI.mainTheme.themeAuthor = "An Author"
|
nwGUI.mainTheme.themeAuthor = "An Author"
|
||||||
@@ -72,12 +71,11 @@ def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgAbout_QtDialog(monkeypatch, nwGUI):
|
def testDlgAbout_QtDialog(monkeypatch, nwGUI):
|
||||||
"""Test the Qt about dialogs.
|
"""Test the Qt about dialogs."""
|
||||||
"""
|
|
||||||
monkeypatch.setattr(QMessageBox, "aboutQt", lambda *a, **k: None)
|
monkeypatch.setattr(QMessageBox, "aboutQt", lambda *a, **k: None)
|
||||||
|
|
||||||
# Open About
|
# 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
|
assert nwGUI.showAboutQtDialog() is True
|
||||||
nwGUI.mainMenu.aAboutQt.activate(QAction.Trigger)
|
nwGUI.mainMenu.aAboutQt.activate(QAction.Trigger)
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
||||||
"""Test the quote symbols dialog.
|
"""Test the quote symbols dialog."""
|
||||||
"""
|
|
||||||
nwQuot = GuiQuoteSelect(nwGUI)
|
nwQuot = GuiQuoteSelect(nwGUI)
|
||||||
nwQuot.show()
|
nwQuot.show()
|
||||||
|
|
||||||
@@ -58,8 +57,7 @@ def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
|
def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
|
||||||
"""Test the check for updates dialog.
|
"""Test the check for updates dialog."""
|
||||||
"""
|
|
||||||
nwUpdate = GuiUpdates(nwGUI)
|
nwUpdate = GuiUpdates(nwGUI)
|
||||||
nwUpdate.show()
|
nwUpdate.show()
|
||||||
|
|
||||||
@@ -97,8 +95,7 @@ def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgOther_EditLabel(qtbot, monkeypatch):
|
def testDlgOther_EditLabel(qtbot, monkeypatch):
|
||||||
"""Test the label editor dialog.
|
"""Test the label editor dialog."""
|
||||||
"""
|
|
||||||
monkeypatch.setattr(GuiEditLabel, "exec_", lambda *a: None)
|
monkeypatch.setattr(GuiEditLabel, "exec_", lambda *a: None)
|
||||||
|
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
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))
|
monkeypatch.setattr(GuiEditLabel, "getLabel", lambda *a, text: (text, True))
|
||||||
|
|
||||||
# Create a new project
|
# Create a new project
|
||||||
@@ -64,7 +63,7 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
nwSplit.show()
|
nwSplit.show()
|
||||||
qtbot.addWidget(nwSplit)
|
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.splitLevel.currentData() == 3
|
||||||
assert nwSplit.listBox.count() == 11
|
assert nwSplit.listBox.count() == 11
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ KEY_DELAY = 1
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||||
"""Test initialising the editor.
|
"""Test initialising the editor."""
|
||||||
"""
|
|
||||||
# Open project
|
# Open project
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc)
|
assert nwGUI.openDocument(C.hSceneDoc)
|
||||||
@@ -82,8 +81,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumText, mockRnd):
|
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)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
|
|
||||||
@@ -137,8 +135,7 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumText, mockRnd):
|
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)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
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
|
assert nwGUI.docEditor.saveText() is False
|
||||||
nwGUI.docEditor._nwItem = nwItem
|
nwGUI.docEditor._nwItem = nwItem
|
||||||
|
|
||||||
# Unkown handle
|
# Unknown handle
|
||||||
nwGUI.docEditor._docHandle = "0123456789abcdef"
|
nwGUI.docEditor._docHandle = "0123456789abcdef"
|
||||||
assert nwGUI.docEditor.saveText() is False
|
assert nwGUI.docEditor.saveText() is False
|
||||||
nwGUI.docEditor._docHandle = C.hSceneDoc
|
nwGUI.docEditor._docHandle = C.hSceneDoc
|
||||||
@@ -181,8 +178,7 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_MetaData(qtbot, nwGUI, projPath, mockRnd):
|
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)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
|
|
||||||
@@ -461,8 +457,7 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||||
"""Test the document insert functions.
|
"""Test the document insert functions."""
|
||||||
"""
|
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
|
|
||||||
@@ -544,8 +539,7 @@ def testGuiEditor_Insert(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||||
"""Test the text manipulation functions.
|
"""Test the text manipulation functions."""
|
||||||
"""
|
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
|
|
||||||
@@ -751,8 +745,7 @@ def testGuiEditor_TextManipulation(qtbot, monkeypatch, nwGUI, projPath, ipsumTex
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||||
"""Test the block formatting function.
|
"""Test the block formatting function."""
|
||||||
"""
|
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
|
|
||||||
@@ -1064,8 +1057,7 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||||
"""Test the document editor tags functionality.
|
"""Test the document editor tags functionality."""
|
||||||
"""
|
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
|
|
||||||
@@ -1123,8 +1115,7 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd):
|
||||||
"""Test saving text from the editor.
|
"""Test saving text from the editor."""
|
||||||
"""
|
|
||||||
class MockThreadPool:
|
class MockThreadPool:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -1204,8 +1195,7 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, nwGUI, projPath, ipsumText, m
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
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)
|
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
|
||||||
|
|
||||||
assert nwGUI.openProject(prjLipsum) is True
|
assert nwGUI.openProject(prjLipsum) is True
|
||||||
@@ -1413,8 +1403,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_StaticMethods():
|
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
|
# Check the method that decides if it is allowed to insert a space
|
||||||
# before a colon using the French, Spanish, etc language feature
|
# before a colon using the French, Spanish, etc language feature
|
||||||
assert GuiDocEditor._allowSpaceBeforeColon("", "") is True
|
assert GuiDocEditor._allowSpaceBeforeColon("", "") is True
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ from novelwriter.core.tohtml import ToHtml
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||||
"""Test the document viewer.
|
"""Test the document viewer."""
|
||||||
"""
|
|
||||||
# Open project
|
# Open project
|
||||||
assert nwGUI.openProject(prjLipsum)
|
assert nwGUI.openProject(prjLipsum)
|
||||||
|
|
||||||
@@ -135,7 +134,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
||||||
assert nwGUI.docViewer.docHeader.theTitle.text() == "Characters › Test Title"
|
assert nwGUI.docViewer.docHeader.theTitle.text() == "Characters › Test Title"
|
||||||
|
|
||||||
# Ttile without full path
|
# Title without full path
|
||||||
CONFIG.showFullPath = False
|
CONFIG.showFullPath = False
|
||||||
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
|
||||||
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
|
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
|
|
||||||
# Block Formats
|
# Block Formats
|
||||||
# =============
|
# =============
|
||||||
|
# cSpell:ignore Pellentesque erat nulla posuere commodo
|
||||||
assert nwGUI.docEditor.setCursorPosition(42)
|
assert nwGUI.docEditor.setCursorPosition(42)
|
||||||
|
|
||||||
# Header 1
|
# Header 1
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
assert novelTree.selectedItems()[0] == topItem
|
assert novelTree.selectedItems()[0] == topItem
|
||||||
assert novelView.getSelectedHandle() == (C.hTitlePage, "T0001")
|
assert novelView.getSelectedHandle() == (C.hTitlePage, "T0001")
|
||||||
|
|
||||||
# Refresh using the slot for the butoom
|
# Refresh using the slot for the button
|
||||||
novelBar._refreshNovelTree()
|
novelBar._refreshNovelTree()
|
||||||
assert novelTree.topLevelItem(0).isSelected()
|
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 C.hTitlePage not in theProject.tree
|
||||||
assert nwGUI.docEditor.docHandle() is None
|
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 projTree.permanentlyDeleteItem(C.hChapterDir) is True
|
||||||
assert C.hChapterDir not in theProject.tree
|
assert C.hChapterDir not in theProject.tree
|
||||||
assert C.hChapterDoc 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.hChapterDoc not in theProject.tree
|
||||||
assert C.hSceneDoc 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
|
assert projTree.emptyTrash() is False
|
||||||
|
|
||||||
nwGUI.closeProject()
|
nwGUI.closeProject()
|
||||||
@@ -557,7 +557,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
# No item under menu
|
# No item under menu
|
||||||
assert projTree._openContextMenu(projTree.viewport().rect().bottomRight()) is False
|
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(hTrashRoot)) is True
|
||||||
assert projTree._openContextMenu(itemPos(C.hNovelRoot)) is True
|
assert projTree._openContextMenu(itemPos(C.hNovelRoot)) is True
|
||||||
assert projTree._openContextMenu(itemPos(hNovelNote)) is True
|
assert projTree._openContextMenu(itemPos(hNovelNote)) is True
|
||||||
@@ -936,7 +936,7 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
# Send invalid handle
|
# Send invalid handle
|
||||||
assert projTree.revealNewTreeItem(C.hInvalid) is False
|
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)
|
nHandle = nwGUI.theProject.newFile("Test", C.hNovelRoot)
|
||||||
nwGUI.theProject.tree[nHandle].setParent(None)
|
nwGUI.theProject.tree[nHandle].setParent(None)
|
||||||
assert projTree.revealNewTreeItem(nHandle) is False
|
assert projTree.revealNewTreeItem(nHandle) is False
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ def testGuiTheme_Icons(qtbot, caplog, monkeypatch, nwGUI, tstPaths):
|
|||||||
assert isinstance(qIcon, QIcon)
|
assert isinstance(qIcon, QIcon)
|
||||||
assert qIcon.isNull() is True
|
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")
|
qIcon = iconCache.getIcon("add")
|
||||||
assert isinstance(qIcon, QIcon)
|
assert isinstance(qIcon, QIcon)
|
||||||
assert qIcon.isNull() is False
|
assert qIcon.isNull() is False
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ def testManuscript_Builds(qtbot: QtBot, nwGUI: GuiMain, projPath: Path):
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testManuscript_Features(monkeypatch, qtbot: QtBot, nwGUI: GuiMain, projPath: Path):
|
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)
|
buildTestProject(nwGUI, projPath)
|
||||||
nwGUI.openProject(projPath)
|
nwGUI.openProject(projPath)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user