On 5/09/2012 3:09pm, Kit Randel wrote:
On 05/09/12 16:28, Mike Dewhirst wrote:
I asked about this a couple of weeks ago and the correct solution is
to use a TransactionTestCase

Hi Mike,

I don't want to be explicitly test transactional behaviour, which I
think is the intention behind TransactionTestCase. I just want each test
running a transaction which rolls back on teardown. The django
documentation for TestCase seems to suggest that TestCase should provide
the behaviour I'm wanting:

/class/TestCase
Wraps each test in a transaction.

https://docs.djangoproject.com/en/dev/topics/testing/#testcase

In your earlier post you mention Django 1.2 but the reference you quote above is the dev documentation. There are differences in the docs but I'm not sure what the underlying code differences might be.

You are right though. If you want to test commits and rollbacks TransactionTestCase is your thing. By my reading of both 1.2 and dev docs, vanilla TestCase imported from Django on the other hand should handle commits and rollbacks itself.

As to your second database, I can't help because I have zero experience with multiple databases. However, I think I have recently seen a caveat in the docs somewhere about testing with multiple database. I haven't looked in the 1.2 docs for some time.

Mike

Explicitly calling connection._rollback() in a TransactionTestCase
unfortunately has the same behaviour and only calls ROLLBACK on the
'default' database.


--
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.

Reply via email to