aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2012-07-08 23:53:36 +0200
committerMartin Vilcans <martin@librador.com>2012-07-09 23:04:17 +0200
commit1df405204f57c5392fb74f5538e08a5c5291dae2 (patch)
treed63dcb6769a973e73bb88435cc83e5d092041a56 /tests
parent6bd28965fde5c2c47862c97f21ae751ed98c9356 (diff)
downloadscreenplain-1df405204f57c5392fb74f5538e08a5c5291dae2.tar.gz
Added page break support.
In HTML output, uses style page-break-before: always Closes #3
Diffstat (limited to 'tests')
-rw-r--r--tests/files/page-break.fountain5
-rw-r--r--tests/files/page-break.fountain.html2
-rw-r--r--tests/files_test.py24
-rw-r--r--tests/fountain_test.py12
4 files changed, 41 insertions, 2 deletions
diff --git a/tests/files/page-break.fountain b/tests/files/page-break.fountain
new file mode 100644
index 0000000..941470d
--- /dev/null
+++ b/tests/files/page-break.fountain
@@ -0,0 +1,5 @@
+First some action
+
+====
+
+INT. SOMEWHERE - DAY
diff --git a/tests/files/page-break.fountain.html b/tests/files/page-break.fountain.html
new file mode 100644
index 0000000..7191953
--- /dev/null
+++ b/tests/files/page-break.fountain.html
@@ -0,0 +1,2 @@
+<div class="action"><p>First some action</p></div>
+<h6 class="page-break">INT. SOMEWHERE - DAY</h6>
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)
diff --git a/tests/fountain_test.py b/tests/fountain_test.py
index ab3e9e7..0ca3c72 100644
--- a/tests/fountain_test.py
+++ b/tests/fountain_test.py
@@ -5,7 +5,7 @@
import unittest2
from screenplain.parsers import fountain
from screenplain.types import (
- Slug, Action, Dialog, DualDialog, Transition, Section
+ Slug, Action, Dialog, DualDialog, Transition, Section, PageBreak
)
from screenplain.richstring import plain, italic, empty_string
from StringIO import StringIO
@@ -481,5 +481,15 @@ class TitlePageTests(unittest2.TestCase):
]
self.assertIsNone(fountain.parse_title_page(lines))
+
+class PageBreakTests(unittest2.TestCase):
+ def test_page_break_sets_page_break_flag_on_next_paragraph(self):
+ paras = list(parse([
+ '====',
+ '',
+ 'So here we go'
+ ]))
+ self.assertEquals([PageBreak, Action], [type(p) for p in paras])
+
if __name__ == '__main__':
unittest2.main()