From 85712a53552a6457c9362b4bf037b1ba6a2e45e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Sun, 16 Dec 2012 23:00:11 +0200 Subject: [PATCH] Made sure connections are actually closed in backends tests --- tests/regressiontests/backends/tests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py index 9cfdd73962..934c37d147 100644 --- a/tests/regressiontests/backends/tests.py +++ b/tests/regressiontests/backends/tests.py @@ -565,6 +565,9 @@ class ThreadTests(TestCase): # connections[DEFAULT_DB_ALIAS] does. from django.db import connections connection = connections[DEFAULT_DB_ALIAS] + # Allow thread sharing so the connection can be closed by the + # main thread. + connection.allow_thread_sharing = True connection.cursor() connections_set.add(connection) for x in range(2): @@ -579,7 +582,7 @@ class ThreadTests(TestCase): # connection opened in the main thread will automatically be closed on # teardown). for conn in connections_set: - if conn != connection: + if conn is not connection: conn.close() def test_connections_thread_local(self): @@ -606,7 +609,7 @@ class ThreadTests(TestCase): # connection opened in the main thread will automatically be closed on # teardown). for conn in connections_set: - if conn != connection: + if conn is not connection: conn.close() def test_pass_connection_between_threads(self):