From 0f00560d45ab2931647b0cbe44a27c37c576c6dc Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 8 Dec 2020 07:28:59 +0100 Subject: [PATCH] Refs #32233 -- Added tests for nonexistent cache backend. --- tests/cache/tests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/cache/tests.py b/tests/cache/tests.py index dd4d441ad1..7172b5e9d9 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -2504,3 +2504,16 @@ class CacheHandlerTest(SimpleTestCase): msg = "Could not find config for 'nonexistent' in settings.CACHES" with self.assertRaisesMessage(InvalidCacheBackendError, msg): caches['nonexistent'] + + def test_nonexistent_backend(self): + 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']