summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-12-26 12:45:40 -0500
committerTim Graham <timograham@gmail.com>2015-01-17 09:55:18 -0500
commitf635d759354842e46901ed1ae1be5f5a0b81e567 (patch)
tree3290dea9edbd45849e9dd525a9aa7f69a75486a8
parentd038c547b5ce585cbf9ef5bb7e5298f52e4a243b (diff)
Removed support for old-style test database settings per deprecation timeline.
-rw-r--r--django/db/utils.py39
-rw-r--r--docs/ref/settings.txt110
-rw-r--r--tests/backends/tests.py122
3 files changed, 1 insertions, 270 deletions
diff --git a/django/db/utils.py b/django/db/utils.py
index f6e5a9b0f8..ea622cddc6 100644
--- a/django/db/utils.py
+++ b/django/db/utils.py
@@ -2,11 +2,9 @@ from importlib import import_module
import os
import pkgutil
from threading import local
-import warnings
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
-from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from django.utils._os import upath
@@ -178,13 +176,6 @@ class ConnectionHandler(object):
for setting in ['NAME', 'USER', 'PASSWORD', 'HOST', 'PORT']:
conn.setdefault(setting, '')
- TEST_SETTING_RENAMES = {
- 'CREATE': 'CREATE_DB',
- 'USER_CREATE': 'CREATE_USER',
- 'PASSWD': 'PASSWORD',
- }
- TEST_SETTING_RENAMES_REVERSE = {v: k for k, v in TEST_SETTING_RENAMES.items()}
-
def prepare_test_settings(self, alias):
"""
Makes sure the test settings are available in the 'TEST' sub-dictionary.
@@ -194,37 +185,7 @@ class ConnectionHandler(object):
except KeyError:
raise ConnectionDoesNotExist("The connection %s doesn't exist" % alias)
- test_dict_set = 'TEST' in conn
test_settings = conn.setdefault('TEST', {})
- old_test_settings = {}
- for key, value in six.iteritems(conn):
- if key.startswith('TEST_'):
- new_key = key[5:]
- new_key = self.TEST_SETTING_RENAMES.get(new_key, new_key)
- old_test_settings[new_key] = value
-
- if old_test_settings:
- if test_dict_set:
- if test_settings != old_test_settings:
- raise ImproperlyConfigured(
- "Connection '%s' has mismatched TEST and TEST_* "
- "database settings." % alias)
- else:
- test_settings.update(old_test_settings)
- for key, _ in six.iteritems(old_test_settings):
- warnings.warn("In Django 1.9 the TEST_%s connection setting will be moved "
- "to a %s entry in the TEST setting" %
- (self.TEST_SETTING_RENAMES_REVERSE.get(key, key), key),
- RemovedInDjango19Warning, stacklevel=2)
-
- for key in list(conn.keys()):
- if key.startswith('TEST_'):
- del conn[key]
- # Check that they didn't just use the old name with 'TEST_' removed
- for key, new_key in six.iteritems(self.TEST_SETTING_RENAMES):
- if key in test_settings:
- warnings.warn("Test setting %s was renamed to %s; specified value (%s) ignored" %
- (key, new_key, test_settings[key]), stacklevel=2)
for key in ['CHARSET', 'COLLATION', 'NAME', 'MIRROR']:
test_settings.setdefault(key, None)
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index db2850da6d..dfbb10c60d 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -853,116 +853,6 @@ This is an Oracle-specific setting.
The maximum size that the DATAFILE_TMP is allowed to grow to.
-.. setting:: OLD_TEST_CHARSET
-
-TEST_CHARSET
-~~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`CHARSET <TEST_CHARSET>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_COLLATION
-
-TEST_COLLATION
-~~~~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`COLLATION <TEST_COLLATION>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_DEPENDENCIES
-
-TEST_DEPENDENCIES
-~~~~~~~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`DEPENDENCIES <TEST_DEPENDENCIES>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_MIRROR
-
-TEST_MIRROR
-~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`MIRROR <TEST_MIRROR>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_NAME
-
-TEST_NAME
-~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`NAME <TEST_NAME>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_CREATE
-
-TEST_CREATE
-~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`CREATE_DB <TEST_CREATE>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_USER
-
-TEST_USER
-~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`USER <TEST_USER>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_USER_CREATE
-
-TEST_USER_CREATE
-~~~~~~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`CREATE_USER <TEST_USER_CREATE>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_PASSWD
-
-TEST_PASSWD
-~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`PASSWORD <TEST_PASSWD>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_TBLSPACE
-
-TEST_TBLSPACE
-~~~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`TBLSPACE <TEST_TBLSPACE>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
-.. setting:: OLD_TEST_TBLSPACE_TMP
-
-TEST_TBLSPACE_TMP
-~~~~~~~~~~~~~~~~~
-
-.. deprecated:: 1.7
-
- Use the :setting:`TBLSPACE_TMP <TEST_TBLSPACE_TMP>` entry in the
- :setting:`TEST <DATABASE-TEST>` dictionary.
-
.. setting:: DATABASE_ROUTERS
DATABASE_ROUTERS
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 3d4185e762..04b5cd5b01 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -24,9 +24,8 @@ from django.db.models.sql.constants import CURSOR
from django.db.utils import ConnectionHandler
from django.test import (TestCase, TransactionTestCase, mock, override_settings,
skipUnlessDBFeature, skipIfDBFeature)
-from django.test.utils import ignore_warnings, str_prefix
+from django.test.utils import str_prefix
from django.utils import six
-from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.six.moves import range
from . import models
@@ -1081,125 +1080,6 @@ class BackendUtilTests(TestCase):
'1234600000')
-@ignore_warnings(category=UserWarning,
- message="Overriding setting DATABASES can lead to unexpected behavior")
-class DBTestSettingsRenamedTests(TestCase):
-
- mismatch_msg = ("Connection 'test-deprecation' has mismatched TEST "
- "and TEST_* database settings.")
-
- def setUp(self):
- super(DBTestSettingsRenamedTests, self).setUp()
- self.handler = ConnectionHandler()
- self.db_settings = {'default': {}}
-
- def test_mismatched_database_test_settings_1(self):
- # if the TEST setting is used, all TEST_* keys must appear in it.
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {},
- 'TEST_NAME': 'foo',
- }
- })
- with override_settings(DATABASES=self.db_settings):
- with self.assertRaisesMessage(ImproperlyConfigured, self.mismatch_msg):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_mismatched_database_test_settings_2(self):
- # if the TEST setting is used, all TEST_* keys must match.
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {'NAME': 'foo'},
- 'TEST_NAME': 'bar',
- },
- })
- with override_settings(DATABASES=self.db_settings):
- with self.assertRaisesMessage(ImproperlyConfigured, self.mismatch_msg):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_mismatched_database_test_settings_3(self):
- # Verifies the mapping of an aliased key.
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {'CREATE_DB': 'foo'},
- 'TEST_CREATE': 'bar',
- },
- })
- with override_settings(DATABASES=self.db_settings):
- with self.assertRaisesMessage(ImproperlyConfigured, self.mismatch_msg):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_mismatched_database_test_settings_4(self):
- # Verifies the mapping of an aliased key when the aliased key is missing.
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {},
- 'TEST_CREATE': 'bar',
- },
- })
- with override_settings(DATABASES=self.db_settings):
- with self.assertRaisesMessage(ImproperlyConfigured, self.mismatch_msg):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_mismatched_settings_old_none(self):
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {'CREATE_DB': None},
- 'TEST_CREATE': '',
- },
- })
- with override_settings(DATABASES=self.db_settings):
- with self.assertRaisesMessage(ImproperlyConfigured, self.mismatch_msg):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_mismatched_settings_new_none(self):
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {},
- 'TEST_CREATE': None,
- },
- })
- with override_settings(DATABASES=self.db_settings):
- with self.assertRaisesMessage(ImproperlyConfigured, self.mismatch_msg):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_matched_test_settings(self):
- # should be able to define new settings and the old, if they match
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {'NAME': 'foo'},
- 'TEST_NAME': 'foo',
- },
- })
- with override_settings(DATABASES=self.db_settings):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_new_settings_only(self):
- # should be able to define new settings without the old
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST': {'NAME': 'foo'},
- },
- })
- with override_settings(DATABASES=self.db_settings):
- self.handler.prepare_test_settings('test-deprecation')
-
- @ignore_warnings(category=RemovedInDjango19Warning)
- def test_old_settings_only(self):
- # should be able to define old settings without the new
- self.db_settings.update({
- 'test-deprecation': {
- 'TEST_NAME': 'foo',
- },
- })
- with override_settings(DATABASES=self.db_settings):
- self.handler.prepare_test_settings('test-deprecation')
-
- def test_empty_settings(self):
- with override_settings(DATABASES=self.db_settings):
- self.handler.prepare_test_settings('default')
-
-
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite specific test.')
@skipUnlessDBFeature('can_share_in_memory_db')
class TestSqliteThreadSharing(TransactionTestCase):