automatically setups a redis instance in a temporary directory, and destroys it after testing
APACHE-2.0 License
testing.redis
automatically setups a redis instance in a temporary directory, and destroys it after testing
.. image:: https://travis-ci.org/tk0miya/testing.redis.svg?branch=master :target: https://travis-ci.org/tk0miya/testing.redis
.. image:: https://coveralls.io/repos/tk0miya/testing.redis/badge.png?branch=master :target: https://coveralls.io/r/tk0miya/testing.redis?branch=master
.. image:: https://codeclimate.com/github/tk0miya/testing.redis/badges/gpa.svg :target: https://codeclimate.com/github/tk0miya/testing.redis
Use easy_install (or pip)::
$ easy_install testing.redis
And testing.redis
requires Redis server.
Create Redis instance using testing.redis.RedisServer
::
import redis import testing.redis
with testing.redis.RedisServer() as redis_server: r = redis.Redis(**redis_server.dsn()) # # do any tests using Redis... #
testing.redis
automatically searchs for redis-server from $PATH
.
If you install redis to other directory, set redis_server
keyword::
redis = testing.redis.RedisServer(redis_server='/path/to/your/redis-server')
testing.redis.RedisServer
executes redis-server
on instantiation.
On deleting RedisServer object, it terminates Redis instance and removes temporary directory.
If you want a database including any fixtures for your apps,
use copy_data_from
keyword::
redis = testing.redis.RedisServer(copy_data_from='/path/to/your/database')
You can specify parameters for Redis with redis_conf
keyword::
redis = testing.redis.RedisServer(redis_conf={'appendonly': 'yes'})
For example, you can setup new Redis server for each testcases on setUp() method::
import unittest import testing.redis
class MyTestCase(unittest.TestCase): def setUp(self): self.redis = testing.redis.RedisServer()
def tearDown(self):
self.redis.stop()
Apache License 2.0
Fix a bug
testing.common.database
packageFix bugs: