mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #6064 -- Added the connection_created signal for when a database connection is created.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10182 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Unit tests for specific database backends.
|
||||
|
||||
# Unit and doctests for specific database backends.
|
||||
import unittest
|
||||
|
||||
from django.db import connection
|
||||
from django.db.backends.signals import connection_created
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Callproc(unittest.TestCase):
|
||||
|
||||
def test_dbms_session(self):
|
||||
@@ -21,6 +18,23 @@ class Callproc(unittest.TestCase):
|
||||
else:
|
||||
return True
|
||||
|
||||
def connection_created_test(sender, **kwargs):
|
||||
print 'connection_created signal'
|
||||
|
||||
__test__ = {'API_TESTS': ''}
|
||||
|
||||
# Unfortunately with sqlite3 the in-memory test database cannot be
|
||||
# closed, and so it cannot be re-opened during testing, and so we
|
||||
# sadly disable this test for now.
|
||||
if settings.DATABASE_ENGINE != 'sqlite3':
|
||||
__test__['API_TESTS'] += """
|
||||
>>> connection_created.connect(connection_created_test)
|
||||
>>> connection.close() # Ensure the connection is closed
|
||||
>>> cursor = connection.cursor()
|
||||
connection_created signal
|
||||
>>> connection_created.disconnect(connection_created_test)
|
||||
>>> cursor = connection.cursor()
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user