Django test database looks empty while test is running

前端 未结 2 1620
说谎
说谎 2020-12-31 05:11

I have a Django project that uses local PostgreSQL server. I\'m using a debugger to debug some weird bugs that I have. While the debugger is stopped on one of the tests, I t

2条回答
  •  情歌与酒
    2020-12-31 06:08

    The database transaction that is being used by django.test.TestCase can be avoided by inheriting from django.test.TransactionTestCase instead of TestCase. Then the data will be visible in the database.

    You might want to just do this temporarily while debugging, so that you get the performance benefits of django.test.TestCase the rest of the time.

    Django docs:
    django.test.TransactionTestCase
    django.test.TestCase

提交回复
热议问题