From c58355251be5d92892163f13bc927c28a65ad30b Mon Sep 17 00:00:00 2001 From: Martin Vilcans Date: Tue, 31 Jan 2012 22:43:41 +0100 Subject: Added tests on actual input/output files. This is to make sure everything works from the command-line level to avoid silly mistakes like the last bug. --- tests/files/simple.spmd | 9 +++++++ tests/files/simple.spmd.fdx | 24 ++++++++++++++++++ tests/files/simple.spmd.html | 4 +++ tests/files_test.py | 59 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 tests/files/simple.spmd create mode 100644 tests/files/simple.spmd.fdx create mode 100644 tests/files/simple.spmd.html create mode 100644 tests/files_test.py (limited to 'tests') diff --git a/tests/files/simple.spmd b/tests/files/simple.spmd new file mode 100644 index 0000000..07d488d --- /dev/null +++ b/tests/files/simple.spmd @@ -0,0 +1,9 @@ +EXT. SOMEWHERE - DAY + +GUY and GURL walks down the street. + +GUY +So what's up? + +GURL +Nothing much. diff --git a/tests/files/simple.spmd.fdx b/tests/files/simple.spmd.fdx new file mode 100644 index 0000000..2e56d82 --- /dev/null +++ b/tests/files/simple.spmd.fdx @@ -0,0 +1,24 @@ + + + + + + EXT. SOMEWHERE - DAY + + + GUY and GURL walks down the street. + + + GUY + + + So what's up? + + + GURL + + + Nothing much. + + + diff --git a/tests/files/simple.spmd.html b/tests/files/simple.spmd.html new file mode 100644 index 0000000..42cc600 --- /dev/null +++ b/tests/files/simple.spmd.html @@ -0,0 +1,4 @@ +

EXT. SOMEWHERE - DAY

+

GUY and GURL walks down the street.

+

GUY

So what's up?

+

GURL

Nothing much.

diff --git a/tests/files_test.py b/tests/files_test.py new file mode 100644 index 0000000..38f8892 --- /dev/null +++ b/tests/files_test.py @@ -0,0 +1,59 @@ +# 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_spmd_to_fdx(self): + actual, expected = self.convert( + 'simple.spmd', 'simple.fdx', 'simple.spmd.fdx') + self.assertMultiLineEqual(expected, actual) + + def test_spmd_to_html(self): + actual, expected = self.convert( + 'simple.spmd', 'simple.html', 'simple.spmd.html', '--bare') + self.assertMultiLineEqual(expected, actual) -- cgit