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