On Sat, 2007-07-28 at 00:13 -0500, Adrian Holovaty wrote: > I propose we add a hook to the unit-test framework that would give > developers access to information about the underlying database queries > in a given test. > > Specifically, I could see (and I currently *have*) needs for the > following assertions: > > * Assert a given custom model method runs a certain, exact number of SQL > queries > > * Assert a given custom model method's SQL contains a certain string > > The only way this is exposed in Django is through > django.db.connection.queries if DEBUG=True.
One thing I've added in my local QuerySet rewrite is the ability to view a query *before* it is executed. So you can view the same information that goes into connection.queries directly, without it needing to go to the database and back. Partly, this is to make debugging broken queries easier -- presently, if they don't survive the trip to the database, you sometimes don't see them in the debug log. However, it should be possible to hook up some way of recording them in-situ in the test framework, too. I'm probably about two or three days away from publishing the first patch of the QuerySet write-up (I'm going to be in airports and offline a bit in the next couple of days). Once I get to New York and am able to respond in a more timely fashion to requests, I'll put the patch up somewhere and people can look at the API for things like that. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
