-
Notifications
You must be signed in to change notification settings - Fork 50
/
test_redis.py
46 lines (34 loc) · 1.16 KB
/
test_redis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
from basic_store import BasicStore, TTLStore
from conftest import ExtendedKeyspaceTests
from simplekv.contrib import ExtendedKeyspaceMixin
import pytest
redis = pytest.importorskip('redis')
from redis import StrictRedis
from redis.exceptions import ConnectionError
class TestRedisStore(TTLStore, BasicStore):
@pytest.yield_fixture()
def store(self):
from simplekv.memory.redisstore import RedisStore
r = StrictRedis()
try:
r.get('anything')
except ConnectionError:
pytest.skip('Could not connect to redis server')
r.flushdb()
yield RedisStore(r)
r.flushdb()
class TestExtendedKeyspaceDictStore(TestRedisStore, ExtendedKeyspaceTests):
@pytest.fixture
def store(self):
from simplekv.memory.redisstore import RedisStore
class ExtendedKeyspaceStore(ExtendedKeyspaceMixin, RedisStore):
pass
r = StrictRedis()
try:
r.get('anything')
except ConnectionError:
pytest.skip('Could not connect to redis server')
r.flushdb()
yield ExtendedKeyspaceStore(r)
r.flushdb()