Skip to main content

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.

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)

Uploaded source

Built Distributions

switchcache-0.1.1-py2.7.egg (5.9 kB view hashes)

Uploaded 2 7

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page