From 1df405204f57c5392fb74f5538e08a5c5291dae2 Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Sun, 8 Jul 2012 23:53:36 +0200 Subject: Added page break support. In HTML output, uses style page-break-before: always Closes #3 --- tests/files_test.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'tests/files_test.py') diff --git a/tests/files_test.py b/tests/files_test.py index 46eb349..0a0480e 100644 --- a/tests/files_test.py +++ b/tests/files_test.py @@ -8,17 +8,33 @@ import unittest2 import tempfile import os.path import shutil +import re from screenplain.main import main source_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'files')) +line_break_re = re.compile('\s*\n\s*') +spaces_re = re.compile('[ \t]+') + def read_file(path): with open(path) as stream: return stream.read() +def clean_string(s): + r"""Removes duplicated spaces and line breaks in a string. + + >>> clean_string('foo \n \nbar\n\n') + 'foo\nbar\n' + >>> clean_string('foo bar') + 'foo bar' + + """ + return spaces_re.sub(' ', line_break_re.sub('\n', s)) + + class ParseTests(unittest2.TestCase): """High level tests that runs Screenplain using command line arguments. """ @@ -47,7 +63,7 @@ class ParseTests(unittest2.TestCase): main(list(options) + [input_path, output_path]) actual = read_file(output_path) expected = read_file(self.source(expected_results_file)) - return actual, expected + return clean_string(actual), clean_string(expected) def test_fountain_to_fdx(self): actual, expected = self.convert( @@ -76,3 +92,9 @@ class ParseTests(unittest2.TestCase): 'boneyard.fountain', 'sections.html', 'boneyard.fountain.html', '--bare') self.assertMultiLineEqual(expected, actual) + + def test_page_break(self): + actual, expected = self.convert( + 'page-break.fountain', 'page-break.html', + 'page-break.fountain.html', '--bare') + self.assertMultiLineEqual(expected, actual) -- cgit