def test_smart_truncate():
    """Test text truncation on word boundaries."""
    patterns = (
        ('text, teeext', 10, 'text,...'),
        ('somethingreallylongwithnospaces', 10, 'somethingr...'),
        ('short enough', 12, 'short enough'),
    )
    for pattern in patterns:
        eq_(smart_truncate(pattern[0], length=pattern[1]), pattern[2])
def test_smart_truncate():
    """Test text truncation on word boundaries."""
    patterns = (
        ('text, teeext', 10, 'text,...'),
        ('somethingreallylongwithnospaces', 10, 'somethingr...'),
        ('short enough', 12, 'short enough'),
    )
    for pattern in patterns:
        eq_(smart_truncate(pattern[0], length=pattern[1]), pattern[2])
Exemple #3
0
 def truncated_description(self):
     """Shorten opinion for list display etc."""
     return smart_truncate(self.description, length=70)