Skip to content

Commit

Permalink
fix failing 'test_cache_url_value' test
Browse files Browse the repository at this point in the history
The test failed for two reasons. One was me changing the error string in a previous commit which
I have adapted the test for now.
The other was that django-cache-url changed its behavior. See #332
  • Loading branch information
lilioid committed Mar 24, 2022
1 parent 42ab54f commit a7f0606
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from contextlib import contextmanager

from django import VERSION as DJANGO_VERSION
from django.test import TestCase
from django.core.exceptions import ImproperlyConfigured

Expand Down Expand Up @@ -61,14 +62,14 @@ def test_value_with_default_and_late_binding(self):

def test_environ_required(self):
for ValueClass in (Value, BooleanValue, IntegerValue,
FloatValue, DecimalValue, ListValue,
TupleValue, SingleNestedTupleValue,
SingleNestedListValue, SetValue,
DictValue, URLValue, EmailValue, IPValue,
RegexValue, PathValue, SecretValue,
DatabaseURLValue, EmailURLValue,
CacheURLValue, BackendsValue,
SearchURLValue, PositiveIntegerValue):
FloatValue, DecimalValue, ListValue,
TupleValue, SingleNestedTupleValue,
SingleNestedListValue, SetValue,
DictValue, URLValue, EmailValue, IPValue,
RegexValue, PathValue, SecretValue,
DatabaseURLValue, EmailURLValue,
CacheURLValue, BackendsValue,
SearchURLValue, PositiveIntegerValue):
value = ValueClass(environ_required=True)
self.assertRaises(ValueRetrievalError, value.setup, "TEST")

Expand Down Expand Up @@ -445,7 +446,7 @@ def test_email_url_value(self):
def test_cache_url_value(self):
cache_setting = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'BACKEND': 'django_redis.cache.RedisCache' if DJANGO_VERSION[0] < 4 else 'django.core.cache.backends.redis.RedisCache',
'LOCATION': 'redis://host:6379/1',
}
}
Expand All @@ -465,7 +466,7 @@ def test_cache_url_value(self):
value.setup('TEST')
self.assertEqual(
cm.exception.args[0],
"Cannot interpret cache URL value 'redis://user@host:port/1'")
"TEST was given an invalid value: Cannot interpret cache URL value 'redis://user@host:port/1'")

def test_search_url_value(self):
value = SearchURLValue()
Expand Down

0 comments on commit a7f0606

Please sign in to comment.