Update tests
This commit is contained in:
@@ -96,18 +96,6 @@ class RegExPatterns:
|
|||||||
rxEnd = "|$" if CONFIG.allowOpenDial else ""
|
rxEnd = "|$" if CONFIG.allowOpenDial else ""
|
||||||
return re.compile(f"\\B[{symO}].*?(?:[{symC}]\\B{rxEnd})", re.UNICODE)
|
return re.compile(f"\\B[{symO}].*?(?:[{symC}]\\B{rxEnd})", re.UNICODE)
|
||||||
|
|
||||||
@property
|
|
||||||
def dialogLine(self) -> re.Pattern:
|
|
||||||
"""Dialogue line rule based on user settings."""
|
|
||||||
sym = re.escape(CONFIG.dialogLine)
|
|
||||||
return re.compile(f"^{sym}.*?$", re.UNICODE)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def narratorBreak(self) -> re.Pattern:
|
|
||||||
"""Dialogue narrator break rule based on user settings."""
|
|
||||||
sym = re.escape(CONFIG.narratorBreak)
|
|
||||||
return re.compile(f"\\B{sym}\\S.*?\\S{sym}\\B", re.UNICODE)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def altDialogStyle(self) -> re.Pattern:
|
def altDialogStyle(self) -> re.Pattern:
|
||||||
"""Dialogue alternative rule based on user settings."""
|
"""Dialogue alternative rule based on user settings."""
|
||||||
|
|||||||
@@ -1251,8 +1251,6 @@ def testFmtToken_Dialogue(mockGUI):
|
|||||||
CONFIG.dialogStyle = 3
|
CONFIG.dialogStyle = 3
|
||||||
CONFIG.altDialogOpen = "::"
|
CONFIG.altDialogOpen = "::"
|
||||||
CONFIG.altDialogClose = "::"
|
CONFIG.altDialogClose = "::"
|
||||||
CONFIG.dialogLine = "\u2013"
|
|
||||||
CONFIG.narratorBreak = "\u2013"
|
|
||||||
|
|
||||||
project = NWProject()
|
project = NWProject()
|
||||||
tokens = BareTokenizer(project)
|
tokens = BareTokenizer(project)
|
||||||
@@ -1305,7 +1303,24 @@ def testFmtToken_Dialogue(mockGUI):
|
|||||||
BlockFmt.NONE
|
BlockFmt.NONE
|
||||||
)]
|
)]
|
||||||
|
|
||||||
|
# Dialogue line
|
||||||
|
CONFIG.dialogLine = "\u2013"
|
||||||
|
tokens.setDialogueHighlight(True)
|
||||||
|
tokens._text = "\u2013 Dialogue line without narrator break.\n"
|
||||||
|
tokens.tokenizeText()
|
||||||
|
assert tokens._blocks == [(
|
||||||
|
BlockTyp.TEXT, "",
|
||||||
|
"\u2013 Dialogue line without narrator break.",
|
||||||
|
[
|
||||||
|
(0, TextFmt.COL_B, "dialog"),
|
||||||
|
(39, TextFmt.COL_E, ""),
|
||||||
|
],
|
||||||
|
BlockFmt.NONE
|
||||||
|
)]
|
||||||
|
|
||||||
# Dialogue line with narrator break
|
# Dialogue line with narrator break
|
||||||
|
CONFIG.narratorBreak = "\u2013"
|
||||||
|
tokens.setDialogueHighlight(True)
|
||||||
tokens._text = "\u2013 Dialogue with a narrator break, \u2013he said,\u2013 see?\n"
|
tokens._text = "\u2013 Dialogue with a narrator break, \u2013he said,\u2013 see?\n"
|
||||||
tokens.tokenizeText()
|
tokens.tokenizeText()
|
||||||
assert tokens._blocks == [(
|
assert tokens._blocks == [(
|
||||||
@@ -1314,7 +1329,7 @@ def testFmtToken_Dialogue(mockGUI):
|
|||||||
[
|
[
|
||||||
(0, TextFmt.COL_B, "dialog"),
|
(0, TextFmt.COL_B, "dialog"),
|
||||||
(34, TextFmt.COL_E, ""),
|
(34, TextFmt.COL_E, ""),
|
||||||
(44, TextFmt.COL_B, "dialog"),
|
(43, TextFmt.COL_B, "dialog"),
|
||||||
(49, TextFmt.COL_E, ""),
|
(49, TextFmt.COL_E, ""),
|
||||||
],
|
],
|
||||||
BlockFmt.NONE
|
BlockFmt.NONE
|
||||||
|
|||||||
@@ -327,35 +327,9 @@ def testTextPatterns_DialogueSpecial():
|
|||||||
CONFIG.fmtDQuoteClose = nwUnicode.U_RDQUO
|
CONFIG.fmtDQuoteClose = nwUnicode.U_RDQUO
|
||||||
|
|
||||||
CONFIG.dialogStyle = 3
|
CONFIG.dialogStyle = 3
|
||||||
CONFIG.dialogLine = nwUnicode.U_ENDASH
|
|
||||||
CONFIG.narratorBreak = nwUnicode.U_ENDASH
|
|
||||||
CONFIG.altDialogOpen = "::"
|
CONFIG.altDialogOpen = "::"
|
||||||
CONFIG.altDialogClose = "::"
|
CONFIG.altDialogClose = "::"
|
||||||
|
|
||||||
# Dialogue Line
|
|
||||||
# =============
|
|
||||||
regEx = REGEX_PATTERNS.dialogLine
|
|
||||||
|
|
||||||
# Check dialogue line in first position
|
|
||||||
assert allMatches(regEx, "\u2013 one two three") == [
|
|
||||||
[("\u2013 one two three", 0, 15)]
|
|
||||||
]
|
|
||||||
|
|
||||||
# Check dialogue line in second position
|
|
||||||
assert allMatches(regEx, " \u2013 one two three") == []
|
|
||||||
|
|
||||||
# Narrator Break
|
|
||||||
# ==============
|
|
||||||
regEx = REGEX_PATTERNS.narratorBreak
|
|
||||||
|
|
||||||
# Narrator break with no padding
|
|
||||||
assert allMatches(regEx, "one \u2013two\u2013 three") == [
|
|
||||||
[("\u2013two\u2013", 4, 9)]
|
|
||||||
]
|
|
||||||
|
|
||||||
# Narrator break with padding
|
|
||||||
assert allMatches(regEx, "one \u2013 two \u2013 three") == []
|
|
||||||
|
|
||||||
# Alternative Dialogue
|
# Alternative Dialogue
|
||||||
# ====================
|
# ====================
|
||||||
regEx = REGEX_PATTERNS.altDialogStyle
|
regEx = REGEX_PATTERNS.altDialogStyle
|
||||||
|
|||||||
Reference in New Issue
Block a user