def message_excerpt(self, obj): return truncate_text(obj.message, 140)[0] if obj.message else ''
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))
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)
def truncated_body(self, obj): return truncate_text(obj.body, 140)[0]
def truncated_body(self, obj): return truncate_text(obj.body, 140)[0] if obj.body else ''
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))