diff options
author | Martin Vilcans <martin@librador.com> | 2011-11-10 23:33:02 +0100 |
---|---|---|
committer | Martin Vilcans <martin@librador.com> | 2011-11-10 23:53:34 +0100 |
commit | 083800d933041f7a35cb19011d68d1e51c7f8b9f (patch) | |
tree | d2c81877c8c31c1b985ddf9e1ff5ff16a31ee998 /tests/fdx_test.py | |
parent | a7f8938b10877ff207688b3ff02f62c55e6c1266 (diff) | |
download | screenplain-083800d933041f7a35cb19011d68d1e51c7f8b9f.tar.gz |
Made RichString non-hierarchical (simpler).
Also: FDX output should have correct line breaks now.
Diffstat (limited to 'tests/fdx_test.py')
-rw-r--r-- | tests/fdx_test.py | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/tests/fdx_test.py b/tests/fdx_test.py index 153a0cf..d97782f 100644 --- a/tests/fdx_test.py +++ b/tests/fdx_test.py @@ -2,8 +2,7 @@ import unittest2 from StringIO import StringIO from screenplain.export.fdx import write_text - -from screenplain.richstring import RichString, Bold, Italic +from screenplain.richstring import plain, bold, italic class OutputTests(unittest2.TestCase): @@ -12,35 +11,45 @@ class OutputTests(unittest2.TestCase): self.out = StringIO() def test_plain_text_should_have_no_style(self): - write_text(self.out, RichString('hello')) + write_text(self.out, plain('hello'), False) self.assertEqual( self.out.getvalue(), - '<Text>hello</Text>' + ' <Text>hello</Text>\n' ) def test_bold_text_should_have_bold_style(self): - write_text(self.out, Bold('hello')) + write_text(self.out, bold('hello'), False) self.assertEqual( self.out.getvalue(), - '<Text style="Bold">hello</Text>' + ' <Text style="Bold">hello</Text>\n' ) def test_sequential_styles(self): - rich = RichString('plain', Bold('b'), Italic('i')) - write_text(self.out, rich) + rich = plain('plain') + bold('b') + italic('i') + write_text(self.out, rich, False) + self.assertEqual( + self.out.getvalue(), + ' <Text>plain</Text>\n' + ' <Text style="Bold">b</Text>\n' + ' <Text style="Italic">i</Text>\n' + ) + + def test_several_styles(self): + rich = bold('outer') + (bold + italic)('inner') + bold('outer') + write_text(self.out, rich, False) self.assertEqual( self.out.getvalue(), - '<Text>plain</Text>' - '<Text style="Bold">b</Text>' - '<Text style="Italic">i</Text>' + ' <Text style="Bold">outer</Text>\n' + ' <Text style="Bold+Italic">inner</Text>\n' + ' <Text style="Bold">outer</Text>\n' ) - def test_nested_styles(self): - rich = Bold('outer', Italic('inner'), 'outer') - write_text(self.out, rich) + def test_write_text_adds_line_break_if_requested(self): + rich = bold('outer') + (bold + italic)('inner') + bold('outer') + write_text(self.out, rich, True) self.assertEqual( self.out.getvalue(), - '<Text style="Bold">outer</Text>' - '<Text style="Bold+Italic">inner</Text>' - '<Text style="Bold">outer</Text>' + ' <Text style="Bold">outer</Text>\n' + ' <Text style="Bold+Italic">inner</Text>\n' + ' <Text style="Bold">outer\n</Text>\n' # note newline ) |