Re: Ticket #5416 -- assertNumQueries

2010-10-11 Thread Alex Gaynor
On Mon, Oct 11, 2010 at 2:05 PM, Jacob Kaplan-Moss wrote: > On Mon, Oct 11, 2010 at 12:29 PM, Alex Gaynor wrote: >> I've uploaded a new patch [...] > > Looks pretty good to me. > > I must say, though, that I'm not completely happy with the API. I find > ``assertNumQueries(number, callable)`` a bi

Re: Ticket #5416 -- assertNumQueries

2010-10-11 Thread Jacob Kaplan-Moss
On Mon, Oct 11, 2010 at 12:29 PM, Alex Gaynor wrote: > I've uploaded a new patch [...] Looks pretty good to me. I must say, though, that I'm not completely happy with the API. I find ``assertNumQueries(number, callable)`` a bit non-obvious. The context manager helps quite a bit, but I'd really p

Re: Ticket #5416 -- assertNumQueries

2010-10-11 Thread Alex Gaynor
On Mon, Oct 11, 2010 at 4:47 AM, Russell Keith-Magee wrote: > On Mon, Oct 11, 2010 at 4:35 PM, Andrew Godwin wrote: >> On 11/10/10 07:05, Alex Gaynor wrote: >>> >>> I think the solution there is something like: >>> >>> @skipUnless(sys.version>= (2, 5)) >>> def test(self): >>>     exec """ >>>    

Re: Ticket #5416 -- assertNumQueries

2010-10-11 Thread Russell Keith-Magee
On Mon, Oct 11, 2010 at 4:35 PM, Andrew Godwin wrote: > On 11/10/10 07:05, Alex Gaynor wrote: >> >> I think the solution there is something like: >> >> @skipUnless(sys.version>= (2, 5)) >> def test(self): >>     exec """ >>        from __future__ import with_statement >>        with self.assertNum

Re: Ticket #5416 -- assertNumQueries

2010-10-11 Thread Andrew Godwin
On 11/10/10 07:05, Alex Gaynor wrote: I think the solution there is something like: @skipUnless(sys.version>= (2, 5)) def test(self): exec """ from __future__ import with_statement with self.assertNumQueries(1): Model.objects.get(pk=2) """ Not exactly beau

Re: Ticket #5416 -- assertNumQueries

2010-10-10 Thread Russell Keith-Magee
On Mon, Oct 11, 2010 at 6:17 AM, Alex Gaynor wrote: > Hey all, > > I've been spending some time with ticket #5416[0], which is a request > for assertNumQueries in tests.  The primary objection Russ had to the > previous patch in this vein was that It uses connection.queries as > opposed to the pro

Re: Ticket #5416 -- assertNumQueries

2010-10-10 Thread Alex Gaynor
On Mon, Oct 11, 2010 at 2:02 AM, Russell Keith-Magee wrote: > 2010/10/11 Mikhail Korobov : >> Hi all, >> >> If it will be a contextmanager then it can also be extended to perform >> like a decorator: http://gist.github.com/573536 >> I think this can be useful. > > Alex and I have spoken about this

Re: Ticket #5416 -- assertNumQueries

2010-10-10 Thread Russell Keith-Magee
2010/10/11 Mikhail Korobov : > Hi all, > > If it will be a contextmanager then it can also be extended to perform > like a decorator: http://gist.github.com/573536 > I think this can be useful. Alex and I have spoken about this (and a couple of other places that context managers would be useful, l

Re: Ticket #5416 -- assertNumQueries

2010-10-10 Thread Mikhail Korobov
Hi all, If it will be a contextmanager then it can also be extended to perform like a decorator: http://gist.github.com/573536 I think this can be useful. On 11 окт, 04:17, Alex Gaynor wrote: > Hey all, > > I've been spending some time with ticket #5416[0], which is a request > for assertNumQuer

Ticket #5416 -- assertNumQueries

2010-10-10 Thread Alex Gaynor
Hey all, I've been spending some time with ticket #5416[0], which is a request for assertNumQueries in tests. The primary objection Russ had to the previous patch in this vein was that It uses connection.queries as opposed to the proposed signal. However, Russ and I spoke last night and neither