Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
Django-Redis-Cache
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared
Django-Redis-Cache
Commits
d8743562
Commit
d8743562
authored
Jul 11, 2015
by
Sean Bleier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #81 from sebleier/python-3-error
Python 3 error
parents
0b3b7d0a
2621370d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
base.py
redis_cache/backends/base.py
+2
-2
sharder.py
redis_cache/sharder.py
+5
-1
base_tests.py
tests/testapp/tests/base_tests.py
+34
-0
No files found.
redis_cache/backends/base.py
View file @
d8743562
...
...
@@ -105,8 +105,8 @@ class BaseRedisCache(BaseCache):
parser_class
=
getattr
(
mod
,
cls_name
)
except
AttributeError
:
raise
ImproperlyConfigured
(
"Could not find parser class '
%
s'"
%
parser_class
)
except
ImportError
,
e
:
raise
ImproperlyConfigured
(
"Could not find module '
%
s'"
%
e
)
except
ImportError
as
ex
:
raise
ImproperlyConfigured
(
"Could not find module '
%
s'"
%
e
x
)
return
parser_class
def
get_pickle_version
(
self
):
...
...
redis_cache/sharder.py
View file @
d8743562
...
...
@@ -3,8 +3,12 @@ from hashlib import md5
from
math
import
log
import
sys
try
:
maxint
=
sys
.
maxint
except
AttributeError
:
maxint
=
sys
.
maxsize
DIGITS
=
int
(
log
(
sys
.
maxint
)
/
log
(
16
))
DIGITS
=
int
(
log
(
maxint
)
/
log
(
16
))
def
make_hash
(
s
):
...
...
tests/testapp/tests/base_tests.py
View file @
d8743562
...
...
@@ -8,6 +8,12 @@ try:
except
ImportError
:
import
pickle
from
django.core.cache
import
get_cache
from
django.core.exceptions
import
ImproperlyConfigured
from
django.test
import
TestCase
try
:
from
django.test
import
override_settings
except
ImportError
:
from
django.test.utils
import
override_settings
import
redis
...
...
@@ -16,6 +22,9 @@ from redis_cache.cache import RedisCache, pool
from
redis_cache.compat
import
DEFAULT_TIMEOUT
LOCATION
=
"127.0.0.1:6381"
# functions/classes for complex data type tests
def
f
():
return
42
...
...
@@ -493,3 +502,28 @@ class BaseRedisTestCase(SetupMixin):
self
.
cache
.
expire
(
'a'
,
20
)
ttl
=
self
.
cache
.
ttl
(
'a'
)
self
.
assertAlmostEqual
(
ttl
,
20
)
class
ConfigurationTestCase
(
SetupMixin
,
TestCase
):
@
override_settings
(
CACHES
=
{
'default'
:
{
'BACKEND'
:
'redis_cache.RedisCache'
,
'LOCATION'
:
LOCATION
,
'OPTIONS'
:
{
'DB'
:
15
,
'PASSWORD'
:
'yadayada'
,
'PARSER_CLASS'
:
'path.to.unknown.class'
,
'PICKLE_VERSION'
:
2
,
'CONNECTION_POOL_CLASS'
:
'redis.ConnectionPool'
,
'CONNECTION_POOL_CLASS_KWARGS'
:
{
'max_connections'
:
2
,
}
},
},
}
)
def
test_bad_parser_import
(
self
):
with
self
.
assertRaises
(
ImproperlyConfigured
):
get_cache
(
'default'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment