mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Made sure connections are actually closed in backends tests
This commit is contained in:
parent
12a96bfa26
commit
85712a5355
@ -565,6 +565,9 @@ class ThreadTests(TestCase):
|
|||||||
# connections[DEFAULT_DB_ALIAS] does.
|
# connections[DEFAULT_DB_ALIAS] does.
|
||||||
from django.db import connections
|
from django.db import connections
|
||||||
connection = connections[DEFAULT_DB_ALIAS]
|
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()
|
connection.cursor()
|
||||||
connections_set.add(connection)
|
connections_set.add(connection)
|
||||||
for x in range(2):
|
for x in range(2):
|
||||||
@ -579,7 +582,7 @@ class ThreadTests(TestCase):
|
|||||||
# connection opened in the main thread will automatically be closed on
|
# connection opened in the main thread will automatically be closed on
|
||||||
# teardown).
|
# teardown).
|
||||||
for conn in connections_set:
|
for conn in connections_set:
|
||||||
if conn != connection:
|
if conn is not connection:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
def test_connections_thread_local(self):
|
def test_connections_thread_local(self):
|
||||||
@ -606,7 +609,7 @@ class ThreadTests(TestCase):
|
|||||||
# connection opened in the main thread will automatically be closed on
|
# connection opened in the main thread will automatically be closed on
|
||||||
# teardown).
|
# teardown).
|
||||||
for conn in connections_set:
|
for conn in connections_set:
|
||||||
if conn != connection:
|
if conn is not connection:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
def test_pass_connection_between_threads(self):
|
def test_pass_connection_between_threads(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user