diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py
index ce1da6d..7892143 100644
a
|
b
|
from django.conf import settings
|
5 | 5 | |
6 | 6 | # The prefix to put on the default database name when creating |
7 | 7 | # the test database. |
| 8 | from django.db.utils import load_backend |
| 9 | |
8 | 10 | TEST_DATABASE_PREFIX = 'test_' |
9 | 11 | |
10 | 12 | class BaseDatabaseCreation(object): |
… |
… |
class BaseDatabaseCreation(object):
|
320 | 322 | if verbosity >= 2: |
321 | 323 | test_db_repr = " ('%s')" % test_database_name |
322 | 324 | print "Destroying test database for alias '%s'%s..." % (self.connection.alias, test_db_repr) |
323 | | self.connection.settings_dict['NAME'] = old_database_name |
324 | 325 | |
325 | | self._destroy_test_db(test_database_name, verbosity) |
| 326 | # Temporarily use a new connection and a copy of the settings dict. |
| 327 | # This prevents the production database from being exposed to potential |
| 328 | # child threads while (or after) the test database is destroyed. Refs |
| 329 | # #10868. |
| 330 | settings_dict = self.connection.settings_dict.copy() |
| 331 | settings_dict['NAME'] = old_database_name |
| 332 | backend = load_backend(settings_dict['ENGINE']) |
| 333 | new_conn = backend.DatabaseWrapper( |
| 334 | settings_dict, |
| 335 | alias='__destroy_test_db__', |
| 336 | allow_thread_sharing=False) |
| 337 | new_conn.creation._destroy_test_db(test_database_name, verbosity) |
326 | 338 | |
327 | 339 | def _destroy_test_db(self, test_database_name, verbosity): |
328 | 340 | "Internal implementation - remove the test db tables." |
diff --git a/django/test/simple.py b/django/test/simple.py
index 1534011..8259f69 100644
a
|
b
|
class DjangoTestSuiteRunner(object):
|
312 | 312 | return unittest.TextTestRunner(verbosity=self.verbosity, failfast=self.failfast).run(suite) |
313 | 313 | |
314 | 314 | def teardown_databases(self, old_config, **kwargs): |
315 | | from django.db import connections |
| 315 | """ |
| 316 | Destroys all the non-mirror databases. |
| 317 | """ |
316 | 318 | old_names, mirrors = old_config |
317 | | # Point all the mirrors back to the originals |
318 | | for alias, old_name in mirrors: |
319 | | connections[alias].settings_dict['NAME'] = old_name |
320 | | # Destroy all the non-mirror databases |
321 | 319 | for connection, old_name, destroy in old_names: |
322 | 320 | if destroy: |
323 | 321 | connection.creation.destroy_test_db(old_name, self.verbosity) |
324 | | else: |
325 | | connection.settings_dict['NAME'] = old_name |
326 | 322 | |
327 | 323 | def teardown_test_environment(self, **kwargs): |
328 | 324 | unittest.removeHandler() |
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
index 9b3c219..a9ce0f4 100644
a
|
b
|
apply URL escaping again. This is wrong for URLs whose unquoted form contains
|
942 | 942 | a ``%xx`` sequence, but such URLs are very unlikely to happen in the wild, |
943 | 943 | since they would confuse browsers too. |
944 | 944 | |
| 945 | Database connections after running the test suite |
| 946 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 947 | |
| 948 | The default test runner used to reset the django.db.connections so that after |
| 949 | the tests were ran, and test databases dropped, new connections would be made |
| 950 | to the production database. This exposed the production database to threads |
| 951 | created in the tests that were for some reason still running. |
| 952 | |
| 953 | If your code relied on connections to the production database after the tests |
| 954 | were ran, you will need to subclass DjangoTestRunner and override its |
| 955 | teardown_databases() method. |
| 956 | |
945 | 957 | Features deprecated in 1.4 |
946 | 958 | ========================== |
947 | 959 | |