def test_string_formatting(self): """ Test the human representation of a message """ message = Message.objects.get(pk=1) truncated_body = truncate_words(message.body, 10) self.assertEqual(message.__str__(), truncated_body)
def __str__(self): """ Human representation, displaying first ten words of the body. """ truncated_body = truncate_words(self.body, 10) return "%(truncated_body)s" % {'truncated_body': truncated_body}
def test_string_formatting(self): """Test the human representation of a message""" message = Message.objects.get(pk=1) truncated_body = truncate_words(message.body, 10) self.assertEqual(message.__str__(), truncated_body)
def __unicode__(self): """ Human representation, displaying first ten words of the body. """ truncated_body = truncate_words(self.body, 10) return "%(truncated_body)s" % {'truncated_body': truncated_body}