On Fri, May 1, 2009 at 1:44 PM, Charlie DeTar <cha...@gmail.com> wrote:
> > Hi, > > I'm writing tests for an application, and want to test cases where > IntegrityError's get raised. However, whenever an IntegrityError > comes up, I can't get the test client to recover -- it always fails > with: > > InternalError: current transaction is aborted, commands ignored until > end of transaction block > > I've tried issuing "transaction.rollback()" after catching the > IntegrityError in my views, and using various different decorators > such as @transaction.commit_on_success and > @transaction.commit_manually. Nothing prevents the InternalError in > the test client. I tried calling "connection._rollback()", which > seems to reset the test, clearing all data and fixtures that have been > installed for the test. > > What is the proper way to "reset" or "rollback" the connection in a > test case after an IntegrityError has been raised? This only seems to > be an issue with PostgresSQL; in sqlite the "current transaction is > aborted, commands ignored" doesn't seem to come up. > What version of Django are you using? It sounds like you may be using a 1.1 (alpha/beta/trunk) level, which means if you want to be able to use transaction methods such as commit or rollback and see their effects, you will need to use a django.test.TransactionTestCase instead of a django.test.TestCase. See: http://docs.djangoproject.com/en/dev/topics/testing/#testcase Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---