Thursday, August 25, 2011

AssertEquals __unicode__

Hi

How do I do that right ?

I have a class like:

class Invoice
...
def __unicode__(self):
return unicode(str(self.created_at.year)+'/'+str(self.id))

and an test here:


def test_invoice_number(self):
invoice = Invoice.objects.create(created_at="2011-07-28",
customer_id=1, payable_at='2012-12-12')
invoice.save()
self.assertEqual("Invoice: 2011/1", invoice)


with the follwoing result:

File "/Users/torsten/PycharmProjects/invoiz/invoice/tests.py", line
22, in test_invoice_number
self.assertEqual("2011/1", invoice)
AssertionError: '2011/1' != <Invoice: 2011/1>


Thanks for help

Torsten

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment