Utils for testing with/without cache
Project description
switchcache
====
Test utils for testing with memcache
## with_cache/no_cache decorators
```python
from switchcache import init, with_cache, no_cache
class Configure:
HOSTS = ['127.0.0.1:11211']
CACHE = {
'foo': 'bar',
'fuga': 'hoge'
}
init(Configure)
@with_cache
def test_with_cache():
<Cache enabled in this function>
@no_cache
def test_no_cache():
<Cache disabled in this function>
```
## "with" clause
```python
from switchcache import cache
def test():
with cache:
<Cache enabled inside "with">
<Cache disabled outside "with">
```
## twice/times decorators
```python
from switchcache import twice, times
@twice
def test_twice(s):
return s
>>> test_twice('foo')
['foo', 'foo']
@times(5)
def test_5_times(s):
return s
>>> test_5_times('bar')
['bar', 'bar', 'bar', 'bar', 'bar']
```
## Note
Make sure HOSTS point to a your testing environment.
Your current caches on memcache will be flushed & overrided.
====
Test utils for testing with memcache
## with_cache/no_cache decorators
```python
from switchcache import init, with_cache, no_cache
class Configure:
HOSTS = ['127.0.0.1:11211']
CACHE = {
'foo': 'bar',
'fuga': 'hoge'
}
init(Configure)
@with_cache
def test_with_cache():
<Cache enabled in this function>
@no_cache
def test_no_cache():
<Cache disabled in this function>
```
## "with" clause
```python
from switchcache import cache
def test():
with cache:
<Cache enabled inside "with">
<Cache disabled outside "with">
```
## twice/times decorators
```python
from switchcache import twice, times
@twice
def test_twice(s):
return s
>>> test_twice('foo')
['foo', 'foo']
@times(5)
def test_5_times(s):
return s
>>> test_5_times('bar')
['bar', 'bar', 'bar', 'bar', 'bar']
```
## Note
Make sure HOSTS point to a your testing environment.
Your current caches on memcache will be flushed & overrided.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
switchcache-0.1.1.tar.gz
(3.2 kB
view hashes)
Built Distributions
switchcache-0.1.1-py2.7.egg
(5.9 kB
view hashes)
Close
Hashes for switchcache-0.1.1.macosx-10.9-intel.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc65f08d1bd0823f8b09cb1097f10867ca5b927863a5f6c95f07c21c899a5701 |
|
MD5 | e64d4efee63d5b110416929ebd83fe4b |
|
BLAKE2b-256 | 44962e3b6041677cae55468e165802a14c33b1012fa3fedf5fd8a5b8cec4420f |