1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #32233 -- Cleaned-up duplicate connection functionality.

This commit is contained in:
Florian Apolloner
2017-10-22 17:30:42 +02:00
committed by Mariusz Felisiak
parent 0f00560d45
commit 98e05ccde4
9 changed files with 143 additions and 147 deletions

19
tests/cache/tests.py vendored
View File

@@ -17,7 +17,8 @@ from unittest import mock, skipIf
from django.conf import settings
from django.core import management, signals
from django.core.cache import (
DEFAULT_CACHE_ALIAS, CacheKeyWarning, InvalidCacheKey, cache, caches,
DEFAULT_CACHE_ALIAS, CacheHandler, CacheKeyWarning, InvalidCacheKey, cache,
caches,
)
from django.core.cache.backends.base import InvalidCacheBackendError
from django.core.cache.utils import make_template_fragment_key
@@ -2501,19 +2502,19 @@ class CacheHandlerTest(SimpleTestCase):
self.assertIsNot(c[0], c[1])
def test_nonexistent_alias(self):
msg = "Could not find config for 'nonexistent' in settings.CACHES"
msg = "The connection 'nonexistent' doesn't exist."
with self.assertRaisesMessage(InvalidCacheBackendError, msg):
caches['nonexistent']
def test_nonexistent_backend(self):
test_caches = CacheHandler({
'invalid_backend': {
'BACKEND': 'django.nonexistent.NonexistentBackend',
},
})
msg = (
"Could not find backend 'django.nonexistent.NonexistentBackend': "
"No module named 'django.nonexistent'"
)
with self.settings(CACHES={
'invalid_backend': {
'BACKEND': 'django.nonexistent.NonexistentBackend',
},
}):
with self.assertRaisesMessage(InvalidCacheBackendError, msg):
caches['invalid_backend']
with self.assertRaisesMessage(InvalidCacheBackendError, msg):
test_caches['invalid_backend']