Example #1
0
 def message_excerpt(self, obj):
     return truncate_text(obj.message, 140)[0] if obj.message else ''
Example #2
0
def test_truncate_text():
    eq_(truncate_text('foobar', 5), ('...', 0))
    eq_(truncate_text('foobar', 5, True), ('fooba...', 0))
    eq_(truncate_text('foobar', 5, True, 'xxx'), ('foobaxxx', 0))
    eq_(truncate_text('foobar', 6), ('foobar...', 0))
    eq_(truncate_text('foobar', 7), ('foobar', 1))
Example #3
0
def test_truncate_text():
    assert truncate_text('foobar', 5) == ('fooba...', 0)
    assert truncate_text('foobar', 5, True) == ('fooba...', 0)
    assert truncate_text('foobar', 5, True, 'xxx') == ('foobaxxx', 0)
    assert truncate_text('foobar', 6) == ('foobar...', 0)
    assert truncate_text('foobar', 7) == ('foobar', 1)
Example #4
0
 def truncated_body(self, obj):
     return truncate_text(obj.body, 140)[0]
Example #5
0
 def message_excerpt(self, obj):
     return truncate_text(obj.message, 140)[0] if obj.message else ''
Example #6
0
 def truncated_body(self, obj):
     return truncate_text(obj.body, 140)[0] if obj.body else ''
Example #7
0
def test_truncate_text():
    eq_(truncate_text("foobar", 5), ("fooba...", 0))
    eq_(truncate_text("foobar", 5, True), ("fooba...", 0))
    eq_(truncate_text("foobar", 5, True, "xxx"), ("foobaxxx", 0))
    eq_(truncate_text("foobar", 6), ("foobar...", 0))
    eq_(truncate_text("foobar", 7), ("foobar", 1))
Example #8
0
def test_truncate_text():
    eq_(truncate_text('foobar', 5), ('...', 0))
    eq_(truncate_text('foobar', 5, True), ('fooba...', 0))
    eq_(truncate_text('foobar', 5, True, 'xxx'), ('foobaxxx', 0))
    eq_(truncate_text('foobar', 6), ('foobar...', 0))
    eq_(truncate_text('foobar', 7), ('foobar', 1))