1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# Copyright (c) 2012 Martin Vilcans
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
from __future__ import with_statement
import unittest2
import tempfile
import os.path
import shutil
from screenplain.main import main
source_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'files'))
def read_file(path):
with open(path) as stream:
return stream.read()
class ParseTests(unittest2.TestCase):
"""High level tests that runs Screenplain using command line arguments.
"""
maxDiff = None
def setUp(self):
self.dir = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self.dir)
def source(self, filename):
return os.path.join(source_dir, filename)
def target(self, name):
return os.path.join(self.dir, name)
def convert(
self,
input_file, output_file, expected_results_file,
*options
):
input_path = self.source(input_file)
output_path = self.target(output_file)
main(list(options) + [input_path, output_path])
actual = read_file(output_path)
expected = read_file(self.source(expected_results_file))
return actual, expected
def test_fountain_to_fdx(self):
actual, expected = self.convert(
'simple.fountain', 'simple.fdx', 'simple.fountain.fdx')
self.assertMultiLineEqual(expected, actual)
def test_fountain_to_html(self):
actual, expected = self.convert(
'simple.fountain', 'simple.html', 'simple.fountain.html', '--bare')
self.assertMultiLineEqual(expected, actual)
def test_scene_numbers(self):
actual, expected = self.convert(
'scene-numbers.fountain', 'scene-numbers.html',
'scene-numbers.fountain.html', '--bare')
self.assertMultiLineEqual(expected, actual)
def test_sections(self):
actual, expected = self.convert(
'sections.fountain', 'sections.html',
'sections.fountain.html', '--bare')
self.assertMultiLineEqual(expected, actual)
def test_boneyard(self):
actual, expected = self.convert(
'boneyard.fountain', 'sections.html',
'boneyard.fountain.html', '--bare')
self.assertMultiLineEqual(expected, actual)
|