Fix tests
This commit is contained in:
@@ -332,6 +332,7 @@ def testCoreToHtml_Methods(dummyGUI):
|
|||||||
"""
|
"""
|
||||||
theProject = NWProject(dummyGUI)
|
theProject = NWProject(dummyGUI)
|
||||||
theHtml = ToHtml(theProject, dummyGUI)
|
theHtml = ToHtml(theProject, dummyGUI)
|
||||||
|
theHtml.setKeepMarkdown(True)
|
||||||
|
|
||||||
# Auto-Replace
|
# Auto-Replace
|
||||||
docText = "Text with <brackets> & short–dash, long—dash …\n"
|
docText = "Text with <brackets> & short–dash, long—dash …\n"
|
||||||
@@ -344,11 +345,11 @@ def testCoreToHtml_Methods(dummyGUI):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Revert on MD
|
# Revert on MD
|
||||||
assert theHtml.theMarkdown == (
|
assert theHtml.theMarkdown[-1] == (
|
||||||
"Text with <brackets> & short–dash, long—dash …\n\n"
|
"Text with <brackets> & short–dash, long—dash …\n\n"
|
||||||
)
|
)
|
||||||
theHtml.doPostProcessing()
|
theHtml.doPostProcessing()
|
||||||
assert theHtml.theMarkdown == docText + "\n"
|
assert theHtml.theMarkdown[-1] == docText + "\n"
|
||||||
|
|
||||||
# With Preview, No Revert
|
# With Preview, No Revert
|
||||||
theHtml.setPreview(True, True)
|
theHtml.setPreview(True, True)
|
||||||
@@ -356,11 +357,11 @@ def testCoreToHtml_Methods(dummyGUI):
|
|||||||
theHtml.doAutoReplace()
|
theHtml.doAutoReplace()
|
||||||
theHtml.tokenizeText()
|
theHtml.tokenizeText()
|
||||||
theHtml.doConvert()
|
theHtml.doConvert()
|
||||||
assert theHtml.theMarkdown == (
|
assert theHtml.theMarkdown[-1] == (
|
||||||
"Text with <brackets> & short–dash, long—dash …\n\n"
|
"Text with <brackets> & short–dash, long—dash …\n\n"
|
||||||
)
|
)
|
||||||
theHtml.doPostProcessing()
|
theHtml.doPostProcessing()
|
||||||
assert theHtml.theMarkdown == (
|
assert theHtml.theMarkdown[-1] == (
|
||||||
"Text with <brackets> & short–dash, long—dash …\n\n"
|
"Text with <brackets> & short–dash, long—dash …\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI):
|
|||||||
theProject = NWProject(dummyGUI)
|
theProject = NWProject(dummyGUI)
|
||||||
theProject.projTree.setSeed(42)
|
theProject.projTree.setSeed(42)
|
||||||
theToken = Tokenizer(theProject, dummyGUI)
|
theToken = Tokenizer(theProject, dummyGUI)
|
||||||
|
theToken.setKeepMarkdown(True)
|
||||||
|
|
||||||
assert theProject.openProject(nwMinimal)
|
assert theProject.openProject(nwMinimal)
|
||||||
sHandle = "8c659a11cd429"
|
sHandle = "8c659a11cd429"
|
||||||
@@ -112,7 +113,7 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI):
|
|||||||
assert theToken.addRootHeading("dummy") is False
|
assert theToken.addRootHeading("dummy") is False
|
||||||
assert theToken.addRootHeading(sHandle) is False
|
assert theToken.addRootHeading(sHandle) is False
|
||||||
assert theToken.addRootHeading("7695ce551d265") is True
|
assert theToken.addRootHeading("7695ce551d265") is True
|
||||||
assert theToken.theMarkdown == "# Notes: Plot\n\n"
|
assert theToken.theMarkdown[-1] == "# Notes: Plot\n\n"
|
||||||
|
|
||||||
# Set text
|
# Set text
|
||||||
assert theToken.setText("dummy") is False
|
assert theToken.setText("dummy") is False
|
||||||
@@ -145,12 +146,6 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI):
|
|||||||
theToken.doAutoReplace()
|
theToken.doAutoReplace()
|
||||||
assert theToken.theText == docTextR
|
assert theToken.theText == docTextR
|
||||||
|
|
||||||
# Access
|
|
||||||
assert theToken.getResult() is None
|
|
||||||
assert theToken.getResultSize() == 0
|
|
||||||
theToken.theResult = ""
|
|
||||||
assert theToken.getResultSize() == 0
|
|
||||||
|
|
||||||
# Post Processing
|
# Post Processing
|
||||||
theToken.theResult = r"This is text with escapes: \** \~~ \__"
|
theToken.theResult = r"This is text with escapes: \** \~~ \__"
|
||||||
theToken.doPostProcessing()
|
theToken.doPostProcessing()
|
||||||
@@ -164,6 +159,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
"""
|
"""
|
||||||
theProject = NWProject(dummyGUI)
|
theProject = NWProject(dummyGUI)
|
||||||
theToken = Tokenizer(theProject, dummyGUI)
|
theToken = Tokenizer(theProject, dummyGUI)
|
||||||
|
theToken.setKeepMarkdown(True)
|
||||||
|
|
||||||
# Header 1
|
# Header 1
|
||||||
theToken.theText = "# Novel Title\n"
|
theToken.theText = "# Novel Title\n"
|
||||||
@@ -172,7 +168,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_HEAD1, 1, "Novel Title", None, Tokenizer.A_NONE),
|
(Tokenizer.T_HEAD1, 1, "Novel Title", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "# Novel Title\n\n"
|
assert theToken.theMarkdown[-1] == "# Novel Title\n\n"
|
||||||
|
|
||||||
# Header 2
|
# Header 2
|
||||||
theToken.theText = "## Chapter One\n"
|
theToken.theText = "## Chapter One\n"
|
||||||
@@ -181,7 +177,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_HEAD2, 1, "Chapter One", None, Tokenizer.A_NONE),
|
(Tokenizer.T_HEAD2, 1, "Chapter One", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "## Chapter One\n\n"
|
assert theToken.theMarkdown[-1] == "## Chapter One\n\n"
|
||||||
|
|
||||||
# Header 3
|
# Header 3
|
||||||
theToken.theText = "### Scene One\n"
|
theToken.theText = "### Scene One\n"
|
||||||
@@ -190,7 +186,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_HEAD3, 1, "Scene One", None, Tokenizer.A_NONE),
|
(Tokenizer.T_HEAD3, 1, "Scene One", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "### Scene One\n\n"
|
assert theToken.theMarkdown[-1] == "### Scene One\n\n"
|
||||||
|
|
||||||
# Header 4
|
# Header 4
|
||||||
theToken.theText = "#### A Section\n"
|
theToken.theText = "#### A Section\n"
|
||||||
@@ -199,7 +195,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_HEAD4, 1, "A Section", None, Tokenizer.A_NONE),
|
(Tokenizer.T_HEAD4, 1, "A Section", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "#### A Section\n\n"
|
assert theToken.theMarkdown[-1] == "#### A Section\n\n"
|
||||||
|
|
||||||
# Comment
|
# Comment
|
||||||
theToken.theText = "% A comment\n"
|
theToken.theText = "% A comment\n"
|
||||||
@@ -208,11 +204,11 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_COMMENT, 1, "A comment", None, Tokenizer.A_NONE),
|
(Tokenizer.T_COMMENT, 1, "A comment", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "\n"
|
assert theToken.theMarkdown[-1] == "\n"
|
||||||
|
|
||||||
theToken.setComments(True)
|
theToken.setComments(True)
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
assert theToken.theMarkdown == "% A comment\n\n"
|
assert theToken.theMarkdown[-1] == "% A comment\n\n"
|
||||||
|
|
||||||
# Symopsis
|
# Symopsis
|
||||||
theToken.theText = "%synopsis: The synopsis\n"
|
theToken.theText = "%synopsis: The synopsis\n"
|
||||||
@@ -227,11 +223,11 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_SYNOPSIS, 1, "The synopsis", None, Tokenizer.A_NONE),
|
(Tokenizer.T_SYNOPSIS, 1, "The synopsis", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "\n"
|
assert theToken.theMarkdown[-1] == "\n"
|
||||||
|
|
||||||
theToken.setSynopsis(True)
|
theToken.setSynopsis(True)
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
assert theToken.theMarkdown == "% synopsis: The synopsis\n\n"
|
assert theToken.theMarkdown[-1] == "% synopsis: The synopsis\n\n"
|
||||||
|
|
||||||
# Keyword
|
# Keyword
|
||||||
theToken.theText = "@char: Bod\n"
|
theToken.theText = "@char: Bod\n"
|
||||||
@@ -240,11 +236,11 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_KEYWORD, 1, "char: Bod", None, Tokenizer.A_NONE),
|
(Tokenizer.T_KEYWORD, 1, "char: Bod", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "\n"
|
assert theToken.theMarkdown[-1] == "\n"
|
||||||
|
|
||||||
theToken.setKeywords(True)
|
theToken.setKeywords(True)
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
assert theToken.theMarkdown == "@char: Bod\n\n"
|
assert theToken.theMarkdown[-1] == "@char: Bod\n\n"
|
||||||
|
|
||||||
# Text
|
# Text
|
||||||
theToken.theText = "Some plain text\non two lines\n\n\n"
|
theToken.theText = "Some plain text\non two lines\n\n\n"
|
||||||
@@ -256,7 +252,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "Some plain text\non two lines\n\n\n\n"
|
assert theToken.theMarkdown[-1] == "Some plain text\non two lines\n\n\n\n"
|
||||||
|
|
||||||
theToken.setBodyText(False)
|
theToken.setBodyText(False)
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
@@ -265,7 +261,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||||
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "\n\n\n"
|
assert theToken.theMarkdown[-1] == "\n\n\n"
|
||||||
theToken.setBodyText(True)
|
theToken.setBodyText(True)
|
||||||
|
|
||||||
# Text Emphasis
|
# Text Emphasis
|
||||||
@@ -283,7 +279,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
),
|
),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "Some **bolded text** on this lines\n\n"
|
assert theToken.theMarkdown[-1] == "Some **bolded text** on this lines\n\n"
|
||||||
|
|
||||||
theToken.theText = "Some _italic text_ on this lines\n"
|
theToken.theText = "Some _italic text_ on this lines\n"
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
@@ -299,7 +295,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
),
|
),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "Some _italic text_ on this lines\n\n"
|
assert theToken.theMarkdown[-1] == "Some _italic text_ on this lines\n\n"
|
||||||
|
|
||||||
theToken.theText = "Some **_bold italic text_** on this lines\n"
|
theToken.theText = "Some **_bold italic text_** on this lines\n"
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
@@ -317,7 +313,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
),
|
),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "Some **_bold italic text_** on this lines\n\n"
|
assert theToken.theMarkdown[-1] == "Some **_bold italic text_** on this lines\n\n"
|
||||||
|
|
||||||
theToken.theText = "Some ~~strikethrough text~~ on this lines\n"
|
theToken.theText = "Some ~~strikethrough text~~ on this lines\n"
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
@@ -333,7 +329,7 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
),
|
),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == "Some ~~strikethrough text~~ on this lines\n\n"
|
assert theToken.theMarkdown[-1] == "Some ~~strikethrough text~~ on this lines\n\n"
|
||||||
|
|
||||||
theToken.theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
theToken.theText = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||||
theToken.tokenizeText()
|
theToken.tokenizeText()
|
||||||
@@ -353,12 +349,12 @@ def testCoreToken_Tokenize(dummyGUI):
|
|||||||
),
|
),
|
||||||
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
(Tokenizer.T_EMPTY, 1, "", None, Tokenizer.A_NONE),
|
||||||
]
|
]
|
||||||
assert theToken.theMarkdown == (
|
assert theToken.theMarkdown[-1] == (
|
||||||
"Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n\n"
|
"Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check the markdown function as well
|
# Check the markdown function as well
|
||||||
assert theToken.getFilteredMarkdown() == (
|
assert theToken.theMarkdown[-1] == (
|
||||||
"Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n\n"
|
"Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,6 @@ def testGuiBuild_Tool(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
|
|||||||
# Close the build tool
|
# Close the build tool
|
||||||
htmlText = nwBuild.htmlText
|
htmlText = nwBuild.htmlText
|
||||||
htmlStyle = nwBuild.htmlStyle
|
htmlStyle = nwBuild.htmlStyle
|
||||||
nwdText = nwBuild.nwdText
|
|
||||||
buildTime = nwBuild.buildTime
|
buildTime = nwBuild.buildTime
|
||||||
nwBuild._doClose()
|
nwBuild._doClose()
|
||||||
|
|
||||||
@@ -222,7 +221,6 @@ def testGuiBuild_Tool(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir):
|
|||||||
assert nwBuild.viewCachedDoc()
|
assert nwBuild.viewCachedDoc()
|
||||||
assert nwBuild.htmlText == htmlText
|
assert nwBuild.htmlText == htmlText
|
||||||
assert nwBuild.htmlStyle == htmlStyle
|
assert nwBuild.htmlStyle == htmlStyle
|
||||||
assert nwBuild.nwdText == nwdText
|
|
||||||
assert nwBuild.buildTime == buildTime
|
assert nwBuild.buildTime == buildTime
|
||||||
|
|
||||||
nwBuild._doClose()
|
nwBuild._doClose()
|
||||||
|
|||||||
Reference in New Issue
Block a user