开发者

how to examine database in the middle of a Django test run?

开发者 https://www.devze.com 2023-03-22 02:04 出处:网络
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 look

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消