& short–dash, long—dash …\n\n"
- )
# Result Size
assert theHtml.getFullResultSize() == 147
diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py
index 4b535730..6b44c93d 100644
--- a/tests/test_core/test_core_tokenizer.py
+++ b/tests/test_core/test_core_tokenizer.py
@@ -24,7 +24,7 @@ import pytest
from tools import C, buildTestProject, readFile
from novelwriter.core.project import NWProject
-from novelwriter.core.tokenizer import Tokenizer
+from novelwriter.core.tokenizer import Tokenizer, stripEscape
class BareTokenizer(Tokenizer):
@@ -203,11 +203,6 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
theToken.doPreProcessing()
assert theToken._theText == docTextR
- # Post Processing
- theToken._theResult = r"This is text with escapes: \** \~~ \__"
- theToken.doPostProcessing()
- assert theToken.theResult == "This is text with escapes: ** ~~ __"
-
# Save File
savePath = fncPath / "dump.nwd"
theToken.saveRawMarkdown(savePath)
@@ -223,6 +218,16 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
# END Test testCoreToken_TextOps
+@pytest.mark.core
+def testCoreToken_StripEscape():
+ """Test the stripEscape helper function.
+ """
+ text = r"This is text with escapes: \** \~~ \__"
+ assert stripEscape(text) == "This is text with escapes: ** ~~ __"
+
+ return
+
+
@pytest.mark.core
def testCoreToken_HeaderFormat(mockGUI):
"""Test the tokenization of header formats in the Tokenizer class.
From 574ed1b2f0e451462fd0544ed8893b3b4fb7ff7b Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Sat, 15 Apr 2023 18:46:32 +0200
Subject: [PATCH 2/2] Improve test coverage
---
tests/test_core/test_core_tohtml.py | 17 ++++++++++++++---
tests/test_core/test_core_tokenizer.py | 8 +++++---
tests/test_core/test_core_toodt.py | 16 +++++++++++++++-
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/tests/test_core/test_core_tohtml.py b/tests/test_core/test_core_tohtml.py
index 50af2307..9f70852c 100644
--- a/tests/test_core/test_core_tohtml.py
+++ b/tests/test_core/test_core_tohtml.py
@@ -378,7 +378,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
@pytest.mark.core
def testCoreToHtml_SpecialCases(mockGUI):
- """Test some special cases that has caused errors in the past.
+ """Test some special cases that have caused errors in the past.
"""
theProject = NWProject(mockGUI)
theHtml = ToHtml(theProject)
@@ -415,8 +415,8 @@ def testCoreToHtml_SpecialCases(mockGUI):
"Test > text <bold> and more.
\n"
)
- # Test for bug #950
- # =================
+ # Test for issue #950
+ # ===================
# See: https://github.com/vkbo/novelWriter/issues/950
theHtml.setComments(True)
@@ -436,6 +436,17 @@ def testCoreToHtml_SpecialCases(mockGUI):
"Heading <1>
\n"
)
+ # Test for issue #1412
+ # ====================
+ # See: https://github.com/vkbo/novelWriter/issues/1412
+
+ theHtml._theText = "Test text \\**_bold_** and more.\n"
+ theHtml.tokenizeText()
+ theHtml.doConvert()
+ assert theHtml.theResult == (
+ "Test text **bold** and more.
\n"
+ )
+
# END Test testCoreToHtml_SpecialCases
diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py
index 6b44c93d..8a2f9631 100644
--- a/tests/test_core/test_core_tokenizer.py
+++ b/tests/test_core/test_core_tokenizer.py
@@ -222,10 +222,12 @@ def testCoreToken_TextOps(monkeypatch, mockGUI, mockRnd, fncPath):
def testCoreToken_StripEscape():
"""Test the stripEscape helper function.
"""
- text = r"This is text with escapes: \** \~~ \__"
- assert stripEscape(text) == "This is text with escapes: ** ~~ __"
+ text1 = "This is text with escapes: \\** \\~~ \\__"
+ text2 = "This is text with escapes: ** ~~ __"
+ assert stripEscape(text1) == "This is text with escapes: ** ~~ __"
+ assert stripEscape(text2) == "This is text with escapes: ** ~~ __"
- return
+# END Test testCoreToken_StripEscape
@pytest.mark.core
diff --git a/tests/test_core/test_core_toodt.py b/tests/test_core/test_core_toodt.py
index fedfbcf3..6e3ea446 100644
--- a/tests/test_core/test_core_toodt.py
+++ b/tests/test_core/test_core_toodt.py
@@ -221,7 +221,21 @@ def testCoreToOdt_TextFormatting(mockGUI):
""
)
- # Tabs and Breaks
+ # Test for issue #1412
+ # ====================
+ # See: https://github.com/vkbo/novelWriter/issues/1412
+
+ theDoc.initDocument()
+ theTxt = "Test text \\**_bold_** and more."
+ theFmt = " I i "
+ theDoc._addTextPar("Standard", oStyle, theTxt, theFmt=theFmt)
+ assert theDoc.getErrors() == []
+ assert xmlToText(theDoc._xText) == (
+ ""
+ "Test text **"
+ "bold** and more."
+ ""
+ )
# END Test testCoreToOdt_TextFormatting