Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

dbfixtures plugin for py.test.

Project description

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

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

Install

$ pip install pytest-dbfixtures

How to use

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


@pytest.fixture(scope='session')
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 = 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.

Examples:

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

Project details


Release history Release notifications

History Node

1.0.0

History Node

0.17.0

History Node

0.16.0

History Node

0.15.0

History Node

0.14.3

History Node

0.14.2

History Node

0.14.1

History Node

0.14.0

History Node

0.13.1

History Node

0.13.0

History Node

0.12.0

History Node

0.11.0

History Node

0.10.0

History Node

0.9.0

History Node

0.8.2

History Node

0.8.1

History Node

0.8.0

History Node

0.7.0

History Node

0.6.0

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.23

History Node

0.4.22

History Node

0.4.21

History Node

0.4.20

History Node

0.4.19

History Node

0.4.18

History Node

0.4.17

History Node

0.4.16

History Node

0.4.15

History Node

0.4.14

History Node

0.4.13

History Node

0.4.12

History Node

0.4.10

History Node

0.4.8

History Node

0.4.6

History Node

0.4.4

History Node

0.4.3

History Node

0.4.2

This version
History Node

0.4.0

History Node

0.3.8.14

History Node

0.3.8.12

History Node

0.3.8.10

History Node

0.3.8.8

History Node

0.3.8.6

History Node

0.3.8.4

History Node

0.3.8.3

History Node

0.3.8

History Node

0.3.6.12

History Node

0.3.6.10

History Node

0.3.6.8

History Node

0.3.6.5

History Node

0.3.6.4

History Node

0.3.6.3

History Node

0.3.6.2

History Node

0.3.6.1

History Node

0.3.6

History Node

0.3.5

History Node

0.3.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

History Node

0.3

History Node

0.2

History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pytest-dbfixtures-0.4.0.tar.gz (5.8 kB) Copy SHA256 hash SHA256 Source None Dec 10, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page