Re: Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread Roger Hunwicks
On Sunday, August 17, 2014 8:39:17 PM UTC+6, James Bennett wrote: > > Not sure about the feasibility, though; would you be willing to work up a > rough implementation of it? > Implementation of the assertion is straightforward, because it can be a direct copy of AssertNumQueries with: self.tes

Re: Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread Josh Smeaton
+1 - useful for user code that guards against accidental poor ORM usage. On Monday, 18 August 2014 05:47:15 UTC+10, jdunck wrote: > > I use this method on my own test subclasses, and I find it useful as a > tripwire: a cause for review and consideration, more than a hard error. Did > the number

Re: Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread Jeremy Dunck
I use this method on my own test subclasses, and I find it useful as a tripwire: a cause for review and consideration, more than a hard error. Did the number of queries go up on this change? Is that reasonable or a mistake? Have we blown the perf budget so we should refactor? Or maybe the number sh

Re: Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread Florian Apolloner
I am not so convinced, what would you put in as the upper limit? While preventing n+1, it still requires you to know what n in this testcase is and changing n can lead to funny errors. Currently we are documenting (hopefully) how those query counts come together, so it's clear what's happening

Re: Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread Shai Berger
On Sunday 17 August 2014 17:36:12 Michael Manfre wrote: > AssertNumQueries is often a problem for 3rd party backends. > AssertMaxQueries would become the same and likely result in poorly written > tests because of the inherent slop factor in the arbitrarily chosen max > value. > I agree with the

Re: Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread James Bennett
I like the idea -- if nothing else, it would provide an easy way to have a test suite discover N+1 problems, especially in templates. Not sure about the feasibility, though; would you be willing to work up a rough implementation of it? -- You received this message because you are subscribed to t

Re: Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread Michael Manfre
AssertNumQueries is often a problem for 3rd party backends. AssertMaxQueries would become the same and likely result in poorly written tests because of the inherent slop factor in the arbitrarily chosen max value. I'm not opposed to Django adding this. I'm opposed to Django using it in its own tes

Would AssertMaxQueries (similar to AssertNumQueries) be a useful addition

2014-08-17 Thread Roger Hunwicks
I'm doing some refactoring of a Django app and I want to make sure that I don't introduce any really poorly performing pages as a result of poor queries. I want to write a test that tries every registered URL and makes sure that none of them has an excessive number of queries. AssertNumQueries