1 2 3 4 5 6 7 8 9 10 11 12 | def check_query_count(num_queries):
def decorator(func):
@wraps(func)
def inner(self, *args, **kwargs):
initial_queries = len(connection.queries)
ret = func(self, *args, **kwargs)
final_queries = len(connection.queries)
if settings.DEBUG:
self.assertEqual(final_queries - initial_queries, num_queries)
return ret
return inner
return decorator
|
More like this
- a template tag to invoke a method on an object with a variable by Scanner 6 years ago
- Forcing unit test runner to abort after failed test by simonbun 5 years, 12 months ago
- Easier chainability with custom QuerySets by bendavis78 1 year, 2 months ago
- UserProfileForm by Natim 3 years, 6 months ago
- Allow filtering and ordering by counts of related query results by exogen 6 years, 1 month ago
Comments