how to examine database in the middle of a Django test run?
I'm trying to be a good programmer and use Django's testing facility. things are going pretty well, but I would like to be able to examine the database when I stop the program in the debugger. It looks like the database work that I do in my setUp routines is wr开发者_如何学Pythonapped in a transaction, so I can't see it from another session (I'm using a PostgreSQL back-end).
I've done some playing around and I don't have TransactionMiddleware installed. I tried decorating my functions with django.db.transactions.commit_on_success, but that is not helping.
Any thoughts?
Possibly using TransactionTestCase instead of TestCase might help.
If you're using django.test.TestCase
, Django wraps each test in a transaction, which is rolled back at the end of the test. You should subclass TransactionTestCase
instead.
精彩评论