diff --git a/django/db/backends/base/creation.py b/django/db/backends/base/creation.py index c7bf97ba46..c94179615d 100644 --- a/django/db/backends/base/creation.py +++ b/django/db/backends/base/creation.py @@ -85,6 +85,13 @@ class BaseDatabaseCreation(object): return test_database_name + def set_as_test_mirror(self, primary_settings_dict): + """ + Set this database up to be used in testing as a mirror of a primary database + whose settings are given + """ + self.connection.settings_dict['NAME'] = primary_settings_dict['NAME'] + def serialize_db_to_string(self): """ Serializes all data in the database into a JSON string. diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py index 1e999f8358..5a5ff517b8 100644 --- a/django/db/backends/oracle/creation.py +++ b/django/db/backends/oracle/creation.py @@ -94,6 +94,14 @@ class DatabaseCreation(BaseDatabaseCreation): return self.connection.settings_dict['NAME'] + def set_as_test_mirror(self, primary_settings_dict): + """ + Set this database up to be used in testing as a mirror of a primary database + whose settings are given + """ + self.connection.settings_dict['USER'] = primary_settings_dict['USER'] + self.connection.settings_dict['PASSWORD'] = primary_settings_dict['PASSWORD'] + def _handle_objects_preventing_db_destruction(self, cursor, parameters, verbosity, autoclobber): # There are objects in the test tablespace which prevent dropping it # The easy fix is to drop the test user -- but are we allowed to do so? diff --git a/django/test/runner.py b/django/test/runner.py index 1106c52803..99bc0e5c02 100644 --- a/django/test/runner.py +++ b/django/test/runner.py @@ -377,8 +377,8 @@ def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, **kwa for alias, mirror_alias in mirrored_aliases.items(): mirrors.append((alias, connections[alias].settings_dict['NAME'])) - connections[alias].settings_dict['NAME'] = ( - connections[mirror_alias].settings_dict['NAME']) + connections[alias].creation.set_as_test_mirror( + connections[mirror_alias].settings_dict) if debug_sql: for alias in connections: