Browse files

Reordered the shutdown process for tests so that all tests force a co…

…nnection close. This is required to prevent some cross-test failures. Thanks to Florian Apolloner for the report and help tracking down the problem.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 52e0bcb commit fffbbe406232fb7403ed33123cd21f9c0996f627 @freakboy3742 freakboy3742 committed Oct 30, 2010
Showing with 11 additions and 3 deletions.
  1. +11 −3 django/test/
@@ -305,9 +305,20 @@ def _post_teardown(self):
""" Performs any post-test things. This includes:
* Putting back the original ROOT_URLCONF if it was changed.
+ * Force closing the connection, so that the next test gets
+ a clean cursor.
+ # Some DB cursors include SQL statements as part of cursor
+ # creation. If you have a test that does rollback, the effect
+ # of these statements is lost, which can effect the operation
+ # of tests (e.g., losing a timezone setting causing objects to
+ # be created with the wrong time).
+ # To make sure this doesn't happen, get a clean connection at the
+ # start of every test.
+ for connection in connections.all():
+ connection.close()
def _fixture_teardown(self):
@@ -575,9 +586,6 @@ def _fixture_teardown(self):
- for connection in connections.all():
- connection.close()
def _deferredSkip(condition, reason):
def decorator(test_func):
if not (isinstance(test_func, type) and issubclass(test_func, TestCase)):

0 comments on commit fffbbe4

Please sign in to comment.