summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Peveler <matt.peveler@gmail.com>2020-10-05 01:50:07 -0400
committerGitHub <noreply@github.com>2020-10-05 01:50:07 -0400
commit13388a33c9e59c852d735eef74b11f3b572e346e (patch)
tree9ee314977f7034d7d68f9128e91fe02df9325150
parent651b9a48228de6fb01a387b57e82d3bc78ae2e17 (diff)
downloadasciidoc-py3-13388a33c9e59c852d735eef74b11f3b572e346e.tar.gz
test newlines as part of test suite (#147)
* test newlines as part of test suite Signed-off-by: Matthew Peveler <matt.peveler@gmail.com> * fix failing toc tests
-rwxr-xr-xasciidoc.py2
-rwxr-xr-xtests/testasciidoc.py23
2 files changed, 15 insertions, 10 deletions
diff --git a/asciidoc.py b/asciidoc.py
index 533771d..4828f91 100755
--- a/asciidoc.py
+++ b/asciidoc.py
@@ -969,7 +969,7 @@ def system(name, args, is_macro=False, attrs=None):
line = subs_attrs(line)
if line is not None:
result.append(line)
- result = '\n'.join(result)
+ result = DEFAULT_NEWLINE.join(result)
else:
assert False
if result and name in ('eval3', 'sys3'):
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):
"""