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 <alex.gay...@gmail.com> 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 proposed signal. However, Russ and I spoke last night > and neither of us had a compelling argument for a signal in favor of > connection.queries and the new logging behavior. The one sticking > point is the use of settings.DEBUG, however we don't want to pollute > the default SQL query path with extra debugging, and the reality is > everyone's ad-hoc implementations of this use it anyways. The other > discussion we had was whether to also offer this function as a > contextmanager. This presents a compelling API, and though we > wouldn't be able to use it in Django itself we could still provide it, > the only issue is that it'd be difficult to properly test (the best > way would probably be a test which uses exec). Any feedback on either > of these issues would be appreciated. > > Alex > > PS: I also converted our test suite to use these and though it's > slightly more verbose in some situations (where we want to make > assertions about the return value), it's a net reduction in code due > to removing the ad-hoc implementations every test has. > > 0:http://code.djangoproject.com/ticket/5416 > -- > "I disapprove of what you say, but I will defend to the death your > right to say it." -- Voltaire > "The people's good is the highest law." -- Cicero > "Code can always be simpler than you think, but never as simple as you > want" -- Me -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.