コード例 #1
0
ファイル: branch.py プロジェクト: pombredanne/launchpad-3
 def mirror_status_message(self):
     """A message from a bad scan or pull, truncated for display."""
     message = self.context.mirror_status_message
     if len(message) <= self.MAXIMUM_STATUS_MESSAGE_LENGTH:
         return message
     return truncate_text(
         message, self.MAXIMUM_STATUS_MESSAGE_LENGTH) + ' ...'
コード例 #2
0
 def test_whitespace_is_preserved(self):
     """The whitespace between words is preserved in the truncated text."""
     text = 'foo  bar\nbaz'
     self.assertEqual(text, helpers.truncate_text(text, len(text)))
コード例 #3
0
 def test_words_arent_split(self):
     """When the truncation would leave only half of the last word, then
     the whole word is removed.
     """
     self.assertEqual('foo', helpers.truncate_text('foo bar', 5))
コード例 #4
0
 def test_single_very_long_word(self):
     """When the first word is longer than the truncation then that word is
     included.
     """
     self.assertEqual('foo', helpers.truncate_text('foooo', 3))
コード例 #5
0
 def test_leaves_shorter_text_unchanged(self):
     """When the text is shorter than the length, nothing is truncated."""
     self.assertEqual('foo', helpers.truncate_text('foo', 10))