diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-18 11:37:26 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-28 15:28:13 +0100 |
| commit | 2ee21d9f0d9eaed0494f3b9cd4b5bc9beffffae5 (patch) | |
| tree | 6c1e2924741812ecae3344382fe79b757a4469a1 /tests | |
| parent | d009ffe436410f6935798d910b0e489d53411dfa (diff) | |
Implemented persistent database connections.
Thanks Anssi Kääriäinen and Karen Tracey for their inputs.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/handlers/tests.py | 17 | ||||
| -rw-r--r-- | tests/httpwrappers/tests.py | 6 | ||||
| -rw-r--r-- | tests/wsgi/tests.py | 8 |
3 files changed, 23 insertions, 8 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index f647bf199b..6eb9bd23fe 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -1,5 +1,6 @@ from django.core.handlers.wsgi import WSGIHandler -from django.core import signals +from django.core.signals import request_started, request_finished +from django.db import close_old_connections from django.test import RequestFactory, TestCase from django.test.utils import override_settings from django.utils import six @@ -7,6 +8,12 @@ from django.utils import six class HandlerTests(TestCase): + def setUp(self): + request_started.disconnect(close_old_connections) + + def tearDown(self): + request_started.connect(close_old_connections) + # Mangle settings so the handler will fail @override_settings(MIDDLEWARE_CLASSES=42) def test_lock_safety(self): @@ -35,12 +42,12 @@ class SignalsTests(TestCase): def setUp(self): self.signals = [] - signals.request_started.connect(self.register_started) - signals.request_finished.connect(self.register_finished) + request_started.connect(self.register_started) + request_finished.connect(self.register_finished) def tearDown(self): - signals.request_started.disconnect(self.register_started) - signals.request_finished.disconnect(self.register_finished) + request_started.disconnect(self.register_started) + request_finished.disconnect(self.register_finished) def register_started(self, **kwargs): self.signals.append('started') diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py index 2964a86034..194232e92f 100644 --- a/tests/httpwrappers/tests.py +++ b/tests/httpwrappers/tests.py @@ -8,7 +8,7 @@ import warnings from django.core.exceptions import SuspiciousOperation from django.core.signals import request_finished -from django.db import close_connection +from django.db import close_old_connections from django.http import (QueryDict, HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseNotAllowed, HttpResponseNotModified, StreamingHttpResponse, @@ -490,10 +490,10 @@ class FileCloseTests(TestCase): def setUp(self): # Disable the request_finished signal during this test # to avoid interfering with the database connection. - request_finished.disconnect(close_connection) + request_finished.disconnect(close_old_connections) def tearDown(self): - request_finished.connect(close_connection) + request_finished.connect(close_old_connections) def test_response(self): filename = os.path.join(os.path.dirname(upath(__file__)), 'abc.txt') diff --git a/tests/wsgi/tests.py b/tests/wsgi/tests.py index 9b7ee68afd..a66258d4eb 100644 --- a/tests/wsgi/tests.py +++ b/tests/wsgi/tests.py @@ -2,7 +2,9 @@ from __future__ import unicode_literals from django.core.exceptions import ImproperlyConfigured from django.core.servers.basehttp import get_internal_wsgi_application +from django.core.signals import request_started from django.core.wsgi import get_wsgi_application +from django.db import close_old_connections from django.test import TestCase from django.test.client import RequestFactory from django.test.utils import override_settings @@ -12,6 +14,12 @@ from django.utils import six, unittest class WSGITest(TestCase): urls = "wsgi.urls" + def setUp(self): + request_started.disconnect(close_old_connections) + + def tearDown(self): + request_started.connect(close_old_connections) + def test_get_wsgi_application(self): """ Verify that ``get_wsgi_application`` returns a functioning WSGI |
