{{{
Traceback (most recent call last):
File
"/home/dom/.virtualenvs/kanisa/src/kanisa/kanisa/tests/views/public.py",
line 31, in test_kanisa_root_view
[banner1.pk, banner2.pk, banner3.pk, banner5.pk, ])
File
"/home/dom/.virtualenvs/kanisa/src/kanisa/.tox/py27-1.5.X/local/lib/python2.7
/site-packages/django/test/testcases.py", line 195, in __exit__
executed, self.num
AssertionError: 5 queries executed, 99 expected
}}}
When an assertNumQueries check fails, the first thing I (and I'd guess
everyone else too) want to know is what queries ran, so it'd be awesome if
an assertNumQueries failure printed the list of queries. Charlie Denton
has a blog post describing how he does this (http://meshy.co.uk/posts
/debugging-assertnumqueries-tests/), but I'd like to see this included in
Django itself - since it seems generally helpful.
This was discussed on django-developers
(https://groups.google.com/forum/#!topic/django-developers/8aUL9d9yyzg).
--
Ticket URL: <https://code.djangoproject.com/ticket/21462>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/21462#comment:1>
Comment (by dominicrodger):
Pull request created - https://github.com/django/django/pull/2055.
I'm not sure what kind of testing this needs - I don't want tests to
depend on the SQL generated, so for now I've just amended the test for
this to check that "Captured queries were" is included in the assertion.
That feels a bit limited, so better ideas welcome.
This is my first non-docs contribution to Django, so do let me know if
there's anything else that needs doing to get this committed.
--
Ticket URL: <https://code.djangoproject.com/ticket/21462#comment:2>
* stage: Accepted => Ready for checkin
Comment:
Test is looking good and the full test suite passes on Py2-3 SQlite3. The
added test also passes on PostgreSQL (Py2-3) and MySQL.
Will commit with the minor suggested changes applied.
--
Ticket URL: <https://code.djangoproject.com/ticket/21462#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"5cd6477fd6ea31eeb4d281e8e431b7a5fb8038a1"]:
{{{
#!CommitTicketReference repository=""
revision="5cd6477fd6ea31eeb4d281e8e431b7a5fb8038a1"
Fixed #21462 -- Made `assertNumQueries` print executed queries on failure.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21462#comment:4>