skip to navigation
skip to content

pytest-dbfixtures 0.4.3

dbfixtures plugin for py.test.

Package Documentation

Latest Version: 1.0.0

py.test clean fixtures: mysql, redis, mongo, rabbitmq

Starts specific database deamon and cleanup all data produced during tests.


$ pip install pytest-dbfixtures

How to use

def test_using_mysql(mysqldb):
    mysqldb.query("SELECT CURRENT_USER()")

def some_session_fixture(mysqldb_session):
    mysqldb_session.query("CREATE DATABASE xyz")
    rows = mysqldb_session.query("USE xyz")

def test_using_redis(redisdb):
    redisdb.set('woof', 'woof')
    woof = redisdb.get('woof')

def test_using_mongo(mongodb):
    db = mongodb['test_database']
    db.test.insert({'woof': 'woof'})
    documents = db.test.find_one()

def test_using_rabbit(rabbitmq):
    channel =

Use your own configure files

Of course you can! Below you can see example configs.

  • pytest_dbfixtures/dbfixtures.conf
  • pytest_dbfixtures/redis.conf
  • pytest_dbfixtures/mongo.conf
  • pytest_dbfixtures/rabbit.conf

If you want to use your own configs pass them as arguments to py.test.


py.test --dbfixtures-config my-dbfixtures.conf

py.test --dbfixtures-config my-dbfixtures.conf --mongo-config my-mongo.conf

py.test --redis-config my-redis.conf
py.test --rabbit-config my-rabbit.conf
File Type Py Version Uploaded on Size
pytest-dbfixtures-0.4.3.tar.gz (md5) Source 2014-01-10 5KB