Update tests
This commit is contained in:
@@ -143,7 +143,6 @@ def testFmtToHtml_ConvertParagraphs(mockGUI):
|
||||
project = NWProject()
|
||||
html = ToHtml(project)
|
||||
html.initDocument()
|
||||
|
||||
html._isNovel = True
|
||||
html._isFirst = True
|
||||
|
||||
@@ -279,20 +278,31 @@ def testFmtToHtml_ConvertParagraphs(mockGUI):
|
||||
"<span style='color: #4271ae'><a href='#tag_europe'>Europe</a></span></p>\n"
|
||||
)
|
||||
|
||||
# Dialogue
|
||||
html.setDialogueHighlight(True)
|
||||
|
||||
@pytest.mark.core
|
||||
def testFmtToHtml_Dialog(mockGUI):
|
||||
"""Test paragraph formats in the ToHtml class."""
|
||||
CONFIG.altDialogOpen = "::"
|
||||
CONFIG.altDialogClose = "::"
|
||||
|
||||
project = NWProject()
|
||||
html = ToHtml(project)
|
||||
html.initDocument()
|
||||
html.setDialogHighlight(True)
|
||||
html._isNovel = True
|
||||
html._isFirst = True
|
||||
|
||||
# Dialog
|
||||
html.setDialogHighlight(True)
|
||||
html._text = "## Chapter\n\nThis text \u201chas dialogue\u201d in it.\n\n"
|
||||
html.tokenizeText()
|
||||
html.doConvert()
|
||||
assert html._pages[-1] == (
|
||||
"<h1 style='page-break-before: always;'>Chapter</h1>\n"
|
||||
"<h1>Chapter</h1>\n"
|
||||
"<p>This text <span style='color: #4271ae'>“has dialogue”</span> in it.</p>\n"
|
||||
)
|
||||
|
||||
# Alt. Dialogue
|
||||
CONFIG.altDialogOpen = "::"
|
||||
CONFIG.altDialogClose = "::"
|
||||
html.setDialogueHighlight(True)
|
||||
# Alt Dialog
|
||||
html._text = "## Chapter\n\nThis text ::has alt dialogue:: in it.\n\n"
|
||||
html.tokenizeText()
|
||||
html.doConvert()
|
||||
@@ -301,8 +311,15 @@ def testFmtToHtml_ConvertParagraphs(mockGUI):
|
||||
"<p>This text <span style='color: #813709'>::has alt dialogue::</span> in it.</p>\n"
|
||||
)
|
||||
|
||||
# Footnotes
|
||||
# =========
|
||||
|
||||
@pytest.mark.core
|
||||
def testFmtToHtml_Footnotes(mockGUI):
|
||||
"""Test paragraph formats in the ToHtml class."""
|
||||
project = NWProject()
|
||||
html = ToHtml(project)
|
||||
html.initDocument()
|
||||
html._isNovel = True
|
||||
html._isFirst = True
|
||||
|
||||
html._text = (
|
||||
"Text with one[footnote:fa] or two[footnote:fb] footnotes.\n\n"
|
||||
|
||||
@@ -1286,7 +1286,7 @@ def testFmtToken_Dialogue(mockGUI):
|
||||
|
||||
project = NWProject()
|
||||
tokens = BareTokenizer(project)
|
||||
tokens.setDialogueHighlight(True)
|
||||
tokens.setDialogHighlight(True)
|
||||
tokens._handle = TMH
|
||||
tokens._isNovel = True
|
||||
|
||||
@@ -1337,7 +1337,10 @@ def testFmtToken_Dialogue(mockGUI):
|
||||
|
||||
# Dialogue line
|
||||
CONFIG.dialogLine = "\u2013"
|
||||
tokens.setDialogueHighlight(True)
|
||||
tokens = BareTokenizer(project)
|
||||
tokens.setDialogHighlight(True)
|
||||
tokens._handle = TMH
|
||||
tokens._isNovel = True
|
||||
tokens._text = "\u2013 Dialogue line without narrator break.\n"
|
||||
tokens.tokenizeText()
|
||||
assert tokens._blocks == [(
|
||||
@@ -1352,16 +1355,19 @@ def testFmtToken_Dialogue(mockGUI):
|
||||
|
||||
# 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 = BareTokenizer(project)
|
||||
tokens.setDialogHighlight(True)
|
||||
tokens._handle = TMH
|
||||
tokens._isNovel = True
|
||||
tokens._text = "\u2013 Dialogue with a narrator break, \u2013he said\u2013, see?\n"
|
||||
tokens.tokenizeText()
|
||||
assert tokens._blocks == [(
|
||||
BlockTyp.TEXT, "",
|
||||
"\u2013 Dialogue with a narrator break, \u2013he said,\u2013 see?",
|
||||
"\u2013 Dialogue with a narrator break, \u2013he said\u2013, see?",
|
||||
[
|
||||
(0, TextFmt.COL_B, "dialog"),
|
||||
(34, TextFmt.COL_E, ""),
|
||||
(43, TextFmt.COL_B, "dialog"),
|
||||
(44, TextFmt.COL_B, "dialog"),
|
||||
(49, TextFmt.COL_E, ""),
|
||||
],
|
||||
BlockFmt.NONE
|
||||
|
||||
@@ -263,7 +263,7 @@ def testFmtToOdt_DialogueFormatting(mockGUI):
|
||||
"""Test formatting of dialogue."""
|
||||
project = NWProject()
|
||||
odt = ToOdt(project, isFlat=True)
|
||||
odt.setDialogueHighlight(True)
|
||||
odt.setDialogHighlight(True)
|
||||
odt.initDocument()
|
||||
oStyle = ODTParagraphStyle("test")
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@ def testFmtToQTextDocument_TextCharFormats(mockGUI):
|
||||
|
||||
# Convert before init
|
||||
doc._text = "Blabla"
|
||||
doc.setDialogueHighlight(True)
|
||||
doc.setDialogHighlight(True)
|
||||
doc.doConvert()
|
||||
doc.tokenizeText()
|
||||
assert doc.document.toPlainText() == ""
|
||||
|
||||
Reference in New Issue
Block a user