Add test coverage

This commit is contained in:
Veronica Berglyd Olsen
2024-05-13 18:31:31 +02:00
parent d64acb038b
commit 1b4cc933e7
4 changed files with 38 additions and 19 deletions
+4 -2
View File
@@ -168,7 +168,8 @@ class GuiDocHighlighter(QSyntaxHighlighter):
} }
self._txtRules.append((rxRule, hlRule)) self._txtRules.append((rxRule, hlRule))
if sym := CONFIG.dialogLine: if CONFIG.dialogLine:
sym = QRegularExpression.escape(CONFIG.dialogLine)
rxRule = QRegularExpression(f"^{sym}.*?$") rxRule = QRegularExpression(f"^{sym}.*?$")
rxRule.setPatternOptions(QRegExUnicode) rxRule.setPatternOptions(QRegExUnicode)
hlRule = { hlRule = {
@@ -176,7 +177,8 @@ class GuiDocHighlighter(QSyntaxHighlighter):
} }
self._txtRules.append((rxRule, hlRule)) self._txtRules.append((rxRule, hlRule))
if sym := CONFIG.narratorBreak: if CONFIG.narratorBreak:
sym = QRegularExpression.escape(CONFIG.narratorBreak)
rxRule = QRegularExpression(f"({sym}\\b)(.*?)(\\b{sym})") rxRule = QRegularExpression(f"({sym}\\b)(.*?)(\\b{sym})")
rxRule.setPatternOptions(QRegExUnicode) rxRule.setPatternOptions(QRegExUnicode)
hlRule = { hlRule = {
+7 -4
View File
@@ -1,5 +1,5 @@
[Meta] [Meta]
timestamp = 2024-04-13 18:57:38 timestamp = 2024-05-13 15:59:59
[Main] [Main]
theme = default theme = default
@@ -59,9 +59,12 @@ showlineendings = False
showmultispaces = True showmultispaces = True
incnoteswcount = True incnoteswcount = True
showfullpath = True showfullpath = True
highlightquotes = True dialogstyle = 2
allowopensquote = False allowopendial = True
allowopendquote = True narratorbreak =
altdialogopen =
altdialogclose =
dialogline =
highlightemph = True highlightemph = True
stopwhenidle = True stopwhenidle = True
useridletime = 300 useridletime = 300
+18 -12
View File
@@ -266,18 +266,21 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths):
assert CONFIG.autoScrollPos == 30 assert CONFIG.autoScrollPos == 30
# Text Highlighting # Text Highlighting
prefs.allowOpenSQuote.setChecked(True) prefs.dialogStyle.setCurrentData(3, 0)
prefs.allowOpenDQuote.setChecked(False) prefs.allowOpenDial.setChecked(False)
prefs.highlightQuotes.setChecked(False) prefs.narratorBreak.setText("")
prefs.dialogLine.setText("")
prefs.altDialogOpen.setText("<")
prefs.altDialogClose.setText(">")
prefs.highlightEmph.setChecked(False) prefs.highlightEmph.setChecked(False)
prefs.showMultiSpaces.setChecked(False) prefs.showMultiSpaces.setChecked(False)
assert prefs.allowOpenSQuote.isEnabled() is False assert CONFIG.dialogStyle == 2
assert prefs.allowOpenDQuote.isEnabled() is False assert CONFIG.allowOpenDial is True
assert CONFIG.narratorBreak == ""
assert CONFIG.highlightQuotes is True assert CONFIG.dialogLine == ""
assert CONFIG.allowOpenSQuote is False assert CONFIG.altDialogOpen == ""
assert CONFIG.allowOpenDQuote is True assert CONFIG.altDialogClose == ""
assert CONFIG.highlightEmph is True assert CONFIG.highlightEmph is True
assert CONFIG.showMultiSpaces is True assert CONFIG.showMultiSpaces is True
@@ -384,9 +387,12 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths):
assert CONFIG.autoScrollPos == 31 assert CONFIG.autoScrollPos == 31
# Text Highlighting # Text Highlighting
assert CONFIG.highlightQuotes is False assert CONFIG.dialogStyle == 3
assert CONFIG.allowOpenSQuote is True assert CONFIG.allowOpenDial is False
assert CONFIG.allowOpenDQuote is False assert CONFIG.narratorBreak == ""
assert CONFIG.dialogLine == ""
assert CONFIG.altDialogOpen == "<"
assert CONFIG.altDialogClose == ">"
assert CONFIG.highlightEmph is False assert CONFIG.highlightEmph is False
assert CONFIG.showMultiSpaces is False assert CONFIG.showMultiSpaces is False
+9 -1
View File
@@ -231,7 +231,15 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
# Text Editor # Text Editor
# =========== # ===========
docEditor: GuiDocEditor = nwGUI.docEditor # Syntax Highlighting
CONFIG.dialogStyle = 3
CONFIG.dialogLine = ""
CONFIG.narratorBreak = ""
CONFIG.altDialogOpen = "<|"
CONFIG.altDialogClose = "|>"
docEditor = nwGUI.docEditor
docEditor._qDocument.syntaxHighlighter.initHighlighter()
# Type something into the document # Type something into the document
nwGUI.switchFocus(nwWidget.EDITOR) nwGUI.switchFocus(nwWidget.EDITOR)