summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Peveler <matt.peveler@gmail.com>2020-10-03 16:25:08 +0000
committerMatthew Peveler <matt.peveler@gmail.com>2020-10-03 16:46:26 +0000
commitcb4b93196a958b88ac2f38a4b43846855dcd5b1d (patch)
treecc26c679f901ce976df945e124314427244b536b
parent651b9a48228de6fb01a387b57e82d3bc78ae2e17 (diff)
downloadasciidoc-py3-test_newlines_2.tar.gz
test newlines as part of test suitetest_newlines_2
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
-rwxr-xr-xtests/testasciidoc.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/testasciidoc.py b/tests/testasciidoc.py
index 4882f80..fef160b 100755
--- a/tests/testasciidoc.py
+++ b/tests/testasciidoc.py
@@ -13,7 +13,6 @@ import sys
sys.path.append(str(Path(__file__).resolve().parent.parent))
import asciidocapi # noqa: E402
-from asciidoc import DEFAULT_NEWLINE # noqa: E402
# Default backends.
BACKENDS = ('html4', 'xhtml11', 'docbook', 'docbook5', 'html5')
@@ -170,11 +169,12 @@ class AsciiDocTest(object):
"""
Return expected test data output for backend.
"""
- with open(self.backend_filename(backend), encoding='utf-8') as open_file:
- result = open_file.readlines()
- # Strip line terminators.
- result = [s.rstrip() for s in result]
- return result
+ with open(
+ self.backend_filename(backend),
+ encoding='utf-8',
+ newline=''
+ ) as open_file:
+ return open_file.readlines()
def generate_expected(self, backend):
"""
@@ -186,7 +186,7 @@ class AsciiDocTest(object):
infile = self.source
outfile = io.StringIO()
asciidoc.execute(infile, outfile, backend)
- return outfile.getvalue().splitlines()
+ return outfile.getvalue().splitlines(keepends=True)
def update_expected(self, backend):
"""
@@ -196,9 +196,14 @@ class AsciiDocTest(object):
if not os.path.isdir(self.datadir):
print('CREATING: %s' % self.datadir)
os.mkdir(self.datadir)
- with open(self.backend_filename(backend), 'w+', encoding='utf-8') as open_file:
+ with open(
+ self.backend_filename(backend),
+ 'w+',
+ encoding='utf-8',
+ newline=''
+ ) as open_file:
print('WRITING: %s' % open_file.name)
- open_file.writelines([s + DEFAULT_NEWLINE for s in lines])
+ open_file.writelines(lines)
def update(self, backend=None, force=False):
"""