Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
language: python
dist: xenial
sudo: true
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7
env:
- DJANGO_VERSION='>=1.11,<2.0'
- DJANGO_VERSION='>=2.0,<2.1'
Expand All @@ -16,6 +19,8 @@ matrix:
env: DJANGO_VERSION='>=2.1,<2.2'
- python: 3.4
env: DJANGO_VERSION='>=2.1,<2.2'
- python: 3.7
env: DJANGO_VERSION='>=1.11,<2.0'
# command to run tests
install: ./install_redis.sh
script: make test DJANGO_VERSION=$DJANGO_VERSION
Expand Down
1 change: 1 addition & 0 deletions install_redis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
: ${REDIS_VERSION:="4.0.11"}

test -d redis || git clone https://github.com/antirez/redis
git -C redis fetch
git -C redis checkout $REDIS_VERSION
make -C redis
5 changes: 3 additions & 2 deletions redis_cache/sharder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from bisect import insort, bisect
import hashlib
from django.utils.encoding import force_text

from django.utils.encoding import force_text
from django.utils.six import integer_types

DIGITS = 8

Expand All @@ -23,7 +24,7 @@ def __init__(self, node, i):
self._position = get_slot(key)

def __gt__(self, other):
if isinstance(other, int):
if isinstance(other, integer_types):
return self._position > other
elif isinstance(other, Node):
return self._position > other._position
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ hiredis==0.2.0
django-nose==1.4.4
nose==1.3.6
msgpack-python==0.4.6
pyyaml==3.11
pyyaml
tox
4 changes: 4 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

DEBUG = True

DATABASES = {
Expand Down Expand Up @@ -33,3 +35,5 @@
}
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
MIDDLEWARE_CLASSES = tuple()

TEST_REDIS_SERVER = os.getenv('REDIS_CACHE_TEST_SERVER', './redis/src/redis-server')
15 changes: 12 additions & 3 deletions tests/testapp/tests/base_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
except ImportError:
import pickle

from django.conf import settings
from django.core.cache import caches
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings
Expand Down Expand Up @@ -52,6 +53,12 @@ def start_redis_servers(servers, db=None, master=None):
db=db,
password=REDIS_PASSWORD
)
server_path = getattr(
settings,
'TEST_REDIS_SERVER',
'./redis/src/redis-server',
)

for i, server in enumerate(servers):
connection_kwargs = parse_connection_kwargs(
server,
Expand All @@ -78,7 +85,7 @@ def start_redis_servers(servers, db=None, master=None):
)
)

args = ['./redis/src/redis-server'] + [
args = [server_path] + [
"--{parameter} {value}".format(parameter=parameter, value=value)
for parameter, value in parameters.items()
]
Expand All @@ -93,8 +100,10 @@ class SetupMixin(object):

@classmethod
def tearDownClass(cls):
for p in cls.processes:
p.kill()
if cls.processes:
for p in cls.processes:
p.kill()

cls.processes = None

# Give redis processes some time to shutdown
Expand Down
22 changes: 22 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[tox]
envlist = py{27,34,35,36}-django{111},
py{34}-django{20},
py{35,36,37}-django{20,21}

install_command = pip install {opts} {packages}

[testenv]
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
py36: python3.6
py37: python3.7
whitelist_externals =
make
passenv =
REDIS_CACHE_TEST_SERVER = {env:REDIS_CACHE_TEST_SERVER:./redis/src/redis-server}
commands =
django111: make test DJANGO_VERSION=">=1.11,<2.0"
django20: make test DJANGO_VERSION=">=2.0,<2.1"
django21: make test DJANGO_VERSION=">=2.1,<2.2"