mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #27170 -- Added DatabaseWrapper class attributes to ease subclassing.
This commit is contained in:
parent
0bbab97c28
commit
7ca3b391b6
11 changed files with 87 additions and 70 deletions
|
@ -32,6 +32,31 @@ from django.utils.six.moves import range
|
|||
from . import models
|
||||
|
||||
|
||||
class DatabaseWrapperTests(SimpleTestCase):
|
||||
|
||||
def test_initialization_class_attributes(self):
|
||||
"""
|
||||
The "initialization" class attributes like client_class and
|
||||
creation_class should be set on the class and reflected in the
|
||||
corresponding instance attributes of the instantiated backend.
|
||||
"""
|
||||
conn = connections[DEFAULT_DB_ALIAS]
|
||||
conn_class = type(conn)
|
||||
attr_names = [
|
||||
('client_class', 'client'),
|
||||
('creation_class', 'creation'),
|
||||
('features_class', 'features'),
|
||||
('introspection_class', 'introspection'),
|
||||
('ops_class', 'ops'),
|
||||
('validation_class', 'validation'),
|
||||
]
|
||||
for class_attr_name, instance_attr_name in attr_names:
|
||||
class_attr_value = getattr(conn_class, class_attr_name)
|
||||
self.assertIsNotNone(class_attr_value)
|
||||
instance_attr_value = getattr(conn, instance_attr_name)
|
||||
self.assertIsInstance(instance_attr_value, class_attr_value)
|
||||
|
||||
|
||||
class DummyBackendTest(SimpleTestCase):
|
||||
|
||||
def test_no_databases(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue