aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2011-09-29 23:56:09 +0200
committerMartin Vilcans <martin@librador.com>2011-09-29 23:56:09 +0200
commit55f57452ad4967247f700608556e96bfaa625425 (patch)
treef06c09e0a32f39569ebb0b96874953a818e02b46 /tests
parent88e2d8a3fb158bad057de614f57e3c2b1490b7c5 (diff)
downloadscreenplain-55f57452ad4967247f700608556e96bfaa625425.tar.gz
Added FDX output
Diffstat (limited to 'tests')
-rw-r--r--tests/fdx_test.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/fdx_test.py b/tests/fdx_test.py
new file mode 100644
index 0000000..9737493
--- /dev/null
+++ b/tests/fdx_test.py
@@ -0,0 +1,45 @@
+import unittest2
+from StringIO import StringIO
+
+from screenplain.export.fdx import write_text
+
+from screenplain.richstring import RichString, Bold, Italic
+
+class OutputTests(unittest2.TestCase):
+
+ def setUp(self):
+ self.out = StringIO()
+
+ def test_plain_text_should_have_no_style(self):
+ write_text(self.out, RichString('hello'))
+ self.assertEqual(
+ self.out.getvalue(),
+ '<Text>hello</Text>'
+ )
+
+ def test_bold_text_should_have_bold_style(self):
+ write_text(self.out, Bold('hello'))
+ self.assertEqual(
+ self.out.getvalue(),
+ '<Text style="Bold">hello</Text>'
+ )
+
+ def test_sequential_styles(self):
+ rich = RichString('plain', Bold('b'), Italic('i'))
+ write_text(self.out, rich)
+ self.assertEqual(
+ self.out.getvalue(),
+ '<Text>plain</Text>'
+ '<Text style="Bold">b</Text>'
+ '<Text style="Italic">i</Text>'
+ )
+
+ def test_nested_styles(self):
+ rich = Bold('outer', Italic('inner'), 'outer')
+ write_text(self.out, rich)
+ self.assertEqual(
+ self.out.getvalue(),
+ '<Text style="Bold">outer</Text>'
+ '<Text style="Bold+Italic">inner</Text>'
+ '<Text style="Bold">outer</Text>'
+ )