Can somebody please explain to me how to properly test Postgres DB errors, particularly IntegrityError. For example i have next test:
class TestSlugs(TestCase): # This slug must be unique b = BookPublisher(slug=self.duplicate_slug) self.assertRaises(IntegrityError, b.save) #check if there's only one BookPublisher self.assertEquals(BookPublisher.objects.count(), 1) Here it catches the IntegrityError but then all operations will fail, because that's how postgres works, ok. I see in docs that i can use transaction.rollback() but where: in test or in save() method? Also, i don't like the idea of writing rollbacks by hand, why can't django just try to save, and if it fails - give me IntegrityError and let me continue to work. --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---