Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed memory leak in tests

The AssertNumQueriesContext didn't reset connection's use_debug_cursor
in case there was an exception. This resulted in leaking query strings
into connection.queries. Maximum memory use pre-patch was around 700MB,
post-patch it is around 200MB for Django's test suite.
  • Loading branch information...
commit 9bc8d887c76b987cc4c76c9a80760e1b315fc80e 1 parent 74a80a5
@akaariai akaariai authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  django/test/
2  django/test/
@@ -162,9 +162,9 @@ def __init__(self, test_case, num, connection):
super(_AssertNumQueriesContext, self).__init__(connection)
def __exit__(self, exc_type, exc_value, traceback):
+ super(_AssertNumQueriesContext, self).__exit__(exc_type, exc_value, traceback)
if exc_type is not None:
- super(_AssertNumQueriesContext, self).__exit__(exc_type, exc_value, traceback)
executed = len(self)
executed, self.num, "%d queries executed, %d expected" % (
Please sign in to comment.
Something went wrong with that request. Please try again.