Skip to main content

A fixture for creating PostgreSQL clusters and databases, and tearing them down again, intended for use during development and testing.

Project description

A Python fixture for creating PostgreSQL clusters and databases, and tearing them down again, intended for use during development and testing.

For more information see the Launchpad project page.

Getting started

Use like any other fixture:

from contextlib import closing
from postgresfixture import ClusterFixture

def test_something(self):
    cluster = self.useFixture(ClusterFixture("db"))
    cluster.createdb("example")
    with closing(cluster.connect("example")) as conn:
        ...
    cluster.dropbdb("example")  # Optional.

This will create a new cluster, create a database called “example”, then tear it all down at the end; nothing will remain on disk. If you want the cluster and its databases to remain on disk, pass preserve=True to the ClusterFixture constructor.

From the command line

Once this package is installed, you’ll have a postgresfixture script. Alternatively you can use python -m postgresfixture to achieve the same thing. Use --help to discover the options available to you.

Project details


Release history Release notifications

History Node

0.4.1

History Node

0.4.0

History Node

0.3.1

History Node

0.3

History Node

0.2.1

This version
History Node

0.2

History Node

0.1.2

History Node

0.1.1

History Node

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
postgresfixture-0.2.tar.gz (6.5 kB) Copy SHA256 hash SHA256 Source None Jan 17, 2014

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