from django.contrib.auth.models import User
from django.test import TestCase, override_settings
class UserTests(TestCase):
# To log queries in tests you need to manually override DEBUG setting
# because testing sets DEBUG=False by default
@override_settings(DEBUG=True)
def test_create_user(self):
User.objects.create()
# "settings.py"
from django.db import connection
print(connection.queries) # Causes error
但是,我得到了下面的错误:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.