I am trying to capture the queries that my code sends to the database by examining the contents of django.db.connection.queries . For some reason, despite the fact that after all automatically generated configuration requests are logged, no additional requests are logged from my own code. The following test case demonstrates behavior.
from django.test import TestCase from django.db import reset_queries, connection from django.contrib.auth.models import User from django.conf import settings class Test1(TestCase): def setUp(self): settings.DEBUG = True def test1(self): self.assert_(settings.DEBUG, 'DEBUG is False') reset_queries()
And here are the results of its launch:
Traceback (most recent call last): File "/Users/jacob/foo/bar_project/baz_application/tests.py", line 246, in test1 self.assert_(connection.queries) AssertionError: No queries
Can anyone shed some light on this? Thanks.
sql django testing
Jacob
source share