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.0.tar.gz
(3.2 kB
view hashes)
Built Distributions
switchcache-0.1.0-py2.7.egg
(5.9 kB
view hashes)
Close
Hashes for switchcache-0.1.0.macosx-10.9-intel.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28892b7973241e167e06f14a7dec4148b3315c321c624adeb0795a4de4d979b6 |
|
MD5 | d04a0da595bca4322c2531654c67293b |
|
BLAKE2b-256 | c11b981e7ca0b78c3a16b266dae17eb64935f57b6a5b896e1fdb29112e61d848 |