|
@@ -97,7 +97,9 @@ configuration::
|
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
|
'NAME': 'myproject',
|
|
|
'HOST': 'dbreplica',
|
|
|
- 'TEST_MIRROR': 'default'
|
|
|
+ 'TEST': {
|
|
|
+ 'MIRROR': 'default',
|
|
|
+ },
|
|
|
# ... plus some other settings
|
|
|
}
|
|
|
}
|
|
@@ -111,8 +113,8 @@ normal activity, any write to ``default`` will appear on ``replica``.
|
|
|
If Django created two independent test databases, this would break any
|
|
|
tests that expected replication to occur. However, the ``replica``
|
|
|
database has been configured as a test mirror (using the
|
|
|
-:setting:`TEST_MIRROR` setting), indicating that under testing,
|
|
|
-``replica`` should be treated as a mirror of ``default``.
|
|
|
+:setting:`MIRROR <TEST_MIRROR>` test setting), indicating that under
|
|
|
+testing, ``replica`` should be treated as a mirror of ``default``.
|
|
|
|
|
|
When the test environment is configured, a test version of ``replica``
|
|
|
will *not* be created. Instead the connection to ``replica``
|
|
@@ -132,41 +134,51 @@ However, no guarantees are made on the creation order of any other
|
|
|
databases in your test setup.
|
|
|
|
|
|
If your database configuration requires a specific creation order, you
|
|
|
-can specify the dependencies that exist using the
|
|
|
-:setting:`TEST_DEPENDENCIES` setting. Consider the following
|
|
|
-(simplified) example database configuration::
|
|
|
+can specify the dependencies that exist using the :setting:`DEPENDENCIES
|
|
|
+<TEST_DEPENDENCIES>` test setting. Consider the following (simplified)
|
|
|
+example database configuration::
|
|
|
|
|
|
DATABASES = {
|
|
|
'default': {
|
|
|
- # ... db settings
|
|
|
- 'TEST_DEPENDENCIES': ['diamonds']
|
|
|
+ # ... db settings
|
|
|
+ 'TEST': {
|
|
|
+ 'DEPENDENCIES': ['diamonds'],
|
|
|
+ },
|
|
|
},
|
|
|
'diamonds': {
|
|
|
- # ... db settings
|
|
|
- 'TEST_DEPENDENCIES': []
|
|
|
+ ... db settings
|
|
|
+ 'TEST': {
|
|
|
+ 'DEPENDENCIES': [],
|
|
|
+ },
|
|
|
},
|
|
|
'clubs': {
|
|
|
# ... db settings
|
|
|
- 'TEST_DEPENDENCIES': ['diamonds']
|
|
|
+ 'TEST': {
|
|
|
+ 'DEPENDENCIES': ['diamonds'],
|
|
|
+ },
|
|
|
},
|
|
|
'spades': {
|
|
|
# ... db settings
|
|
|
- 'TEST_DEPENDENCIES': ['diamonds','hearts']
|
|
|
+ 'TEST': {
|
|
|
+ 'DEPENDENCIES': ['diamonds', 'hearts'],
|
|
|
+ },
|
|
|
},
|
|
|
'hearts': {
|
|
|
# ... db settings
|
|
|
- 'TEST_DEPENDENCIES': ['diamonds','clubs']
|
|
|
+ 'TEST': {
|
|
|
+ 'DEPENDENCIES': ['diamonds', 'clubs'],
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Under this configuration, the ``diamonds`` database will be created first,
|
|
|
as it is the only database alias without dependencies. The ``default`` and
|
|
|
``clubs`` alias will be created next (although the order of creation of this
|
|
|
-pair is not guaranteed); then ``hearts``; and finally ``spades``.
|
|
|
+pair is not guaranteed), then ``hearts``, and finally ``spades``.
|
|
|
|
|
|
-If there are any circular dependencies in the
|
|
|
-:setting:`TEST_DEPENDENCIES` definition, an ``ImproperlyConfigured``
|
|
|
-exception will be raised.
|
|
|
+If there are any circular dependencies in the :setting:`DEPENDENCIES
|
|
|
+<TEST_DEPENDENCIES>` definition, an
|
|
|
+:exc:`~django.core.exceptions.ImproperlyConfigured` exception will be raised.
|
|
|
|
|
|
Advanced features of ``TransactionTestCase``
|
|
|
============================================
|