fix(mailer/models): __str__ method of Attachment returns string

pull/174/head
Christian Merten 4 months ago
parent 69062f3e58
commit 1b8089dd93
Signed by: christian.merten
GPG Key ID: D953D69721B948B3

@ -232,7 +232,7 @@ class Attachment(CommonModel):
max_upload_size=10) max_upload_size=10)
def __str__(self): def __str__(self):
return os.path.basename(self.f.name) if self.f.name else _("Empty") return os.path.basename(self.f.name) if self.f.name else str(_("Empty"))
class Meta: class Meta:
verbose_name = _('attachment') verbose_name = _('attachment')

@ -267,6 +267,5 @@ class AttachmentTestCase(BasicMailerTestCase):
self.attachment.f.name = 'attachments/test_document.pdf' self.attachment.f.name = 'attachments/test_document.pdf'
self.assertEqual(str(self.attachment), 'test_document.pdf') self.assertEqual(str(self.attachment), 'test_document.pdf')
@skip('Fails with TypeError: __str__ returns a lazy translation object, but must return a string.')
def test_str_without_file(self): def test_str_without_file(self):
self.assertEqual(str(self.attachment), _('Empty')) self.assertEqual(str(self.attachment), _('Empty'))

Loading…
Cancel
Save