Example #1
0
"""
create a Text object with a series of possible strings
"""
a = Text('one hour, fourty-five minutes', '1 hour, 45 minutes', '1h45m', '1:45')

"""
create a Text object that has an additional phrase to be displayed
after the first Text object. We will set the attribute trim which will allow
this text to be sliced if there isn't enough room.
"""
b = Text('until armageddon strikes the earth', trim=True)

"""
Create the phrase from the Text objects
"""
phrase = Phrase(a, b)

"""
Generate the phrase
"""
print 'No maximum set, generate phrase\n'
print 'expecting:', 'one hour, fourty-five minutes until armageddon strikes the earth'
print 'received: ', phrase.generate()
print '\n'


"""
Select a different delimiter between the Text objects
"""
print 'No maximum length set, generate phrase with ": " as the delimiter\n'
print 'expecting:', 'one hour, fourty-five minutes: until armageddon strikes the earth'
Example #2
0
 def test_non_trim_length(self):
     test_phrase = Phrase(self.text_a, self.text_b)
     self.assertEqual(test_phrase.non_trim_length( \
         [self.text_a, self.text_b]), 2)