Permalink
Browse files

Made sure global settings are changed in test db creation

There was an assumption that changing connection.settings_dict changed
also the settings.DATABASES values. This assumption is now gone.
  • Loading branch information...
1 parent 1893467 commit 905ea9619b871ded3204b1d0deb7e6fb9b081679 @akaariai akaariai committed Nov 26, 2012
Showing with 7 additions and 4 deletions.
  1. +1 −0 django/db/backends/creation.py
  2. +6 −4 django/db/backends/oracle/creation.py
@@ -281,6 +281,7 @@ def create_test_db(self, verbosity=1, autoclobber=False):
self._create_test_db(verbosity, autoclobber)
self.connection.close()
+ settings.DATABASES[self.connection.alias]["NAME"] = test_database_name
self.connection.settings_dict["NAME"] = test_database_name
# Report syncdb messages at one level lower than that requested.
@@ -104,10 +104,12 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
print("Tests cancelled.")
sys.exit(1)
- self.connection.settings_dict['SAVED_USER'] = self.connection.settings_dict['USER']
- self.connection.settings_dict['SAVED_PASSWORD'] = self.connection.settings_dict['PASSWORD']
- self.connection.settings_dict['TEST_USER'] = self.connection.settings_dict['USER'] = TEST_USER
- self.connection.settings_dict['PASSWORD'] = TEST_PASSWD
+ from django.db import settings
+ real_settings = settings.DATABASES[self.connection.alias]
+ real_settings['SAVED_USER'] = self.connection.settings_dict['SAVED_USER'] = self.connection.settings_dict['USER']
+ real_settings['SAVED_PASSWORD'] = self.connection.settings_dict['SAVED_PASSWORD'] = self.connection.settings_dict['PASSWORD']
+ real_settings['TEST_USER'] = real_settings['USER'] = self.connection.settings_dict['TEST_USER'] = self.connection.settings_dict['USER'] = TEST_USER
+ real_settings['PASSWORD'] = self.connection.settings_dict['PASSWORD'] = TEST_PASSWD
return self.connection.settings_dict['NAME']

0 comments on commit 905ea96

Please sign in to comment.