skip to navigation
skip to content

Not Logged In

switchcache 0.1.1

Utils for testing with/without cache

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.

 
File Type Py Version Uploaded on Size
switchcache-0.1.1-py2.7.egg (md5) Python Egg 2.7 2014-06-17 5KB
switchcache-0.1.1.macosx-10.9-intel.tar.gz (md5)
built for Darwin-13.2.0
"dumb" binary any 2014-06-17 4KB
switchcache-0.1.1.tar.gz (md5) Source 2014-06-17 3KB
  • Downloads (All Versions):
  • 12 downloads in the last day
  • 160 downloads in the last week
  • 706 downloads in the last month
  • Author: Shoji Ihara
  • Home Page: http://github.com/shoz/switchcache
  • Keywords: memcached,test,testing,decorators
  • License:
    switchcache
    The MIT License
    Copyright (c) 2014 Shoji Ihara
    
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    "Software"), to deal in the Software without restriction, including
    without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to
    permit persons to whom the Software is furnished to do so, subject to
    the following conditions:
    
    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Package Index Owner: ihara
  • DOAP record: switchcache-0.1.1.xml