diff options
author | Martin Vilcans <martin@librador.com> | 2011-12-16 20:51:54 +0100 |
---|---|---|
committer | Martin Vilcans <martin@librador.com> | 2011-12-16 23:05:17 +0100 |
commit | 92b56357798394415ae17d4a7253b111be91e01f (patch) | |
tree | 1a61de70cc0ed39e5ad6754f8077eb30028e1f26 /tests/richstring_test.py | |
parent | 55a6e8f70b5125bdd40012f2a66b943a1169fd6b (diff) | |
download | screenplain-92b56357798394415ae17d4a7253b111be91e01f.tar.gz |
Fixed some problems with old RichString tests.
Sometimes the segments of the RichString objects became RichString
objects instead of Segment. That's what you get for dynamic typing
I guess...
Diffstat (limited to 'tests/richstring_test.py')
-rw-r--r-- | tests/richstring_test.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tests/richstring_test.py b/tests/richstring_test.py index 5ce3b4e..0e83aa1 100644 --- a/tests/richstring_test.py +++ b/tests/richstring_test.py @@ -6,7 +6,8 @@ import unittest2 from screenplain.richstring import ( RichString, Segment, Bold, Italic, - plain, bold, italic, underline + plain, bold, italic, underline, + empty_string ) from screenplain.richstring import parse_emphasis from screenplain.types import Slug, Action, Dialog, DualDialog, Transition @@ -15,8 +16,10 @@ from screenplain.types import Slug, Action, Dialog, DualDialog, Transition class LowLevelRichStringTests(unittest2.TestCase): def test_plain_string_has_one_single_segment(self): - s = RichString(plain('hello')) - self.assertEqual((plain('hello'),), s.segments) + s = plain('hello') + self.assertEqual(1, len(s.segments)) + self.assertEqual('hello', s.segments[0].text) + self.assertEqual(set(), s.segments[0].styles) class RichStringOperatorTests(unittest2.TestCase): @@ -28,6 +31,16 @@ class RichStringOperatorTests(unittest2.TestCase): repr(s) ) + def test_repr_on_empty_string(self): + self.assertEquals('empty_string', repr(empty_string)) + + def test_unicode(self): + s = bold('Hello') + plain(' there ') + bold('folks') + self.assertEquals( + u'Hello there folks', + unicode(s) + ) + def test_eq(self): self.assertEquals(bold('Hello'), bold('Hello')) self.assertNotEquals(bold('Hello'), bold('Foo')) @@ -62,14 +75,12 @@ class StyleGeneratorTests(unittest2.TestCase): class RichStringTests(unittest2.TestCase): def test_plain_to_html(self): - self.assertEquals('hello', RichString(plain('hello')).to_html()) + self.assertEquals('hello', plain('hello').to_html()) def test_to_html(self): - s = RichString( - bold('bold'), - plain(' normal '), - italic('italic'), - underline('wonderline') + s = ( + bold('bold') + plain(' normal ') + + italic('italic') + underline('wonderline') ) self.assertEquals( '<strong>bold</strong> normal <em>italic</em><u>wonderline</u>', |