Skip to main content

testing.postgresql automatically setups a postgresql instance in a temporary directory, and destroys it after testing

Install

Use easy_install (or pip):

$ easy_install testing.postgresql

And testing.postgresql requires PostgreSQL server in your PATH.

Usage

Create PostgreSQL instance using testing.postgresql.Postgresql:

import testing.postgresql
postgresql = testing.postgresql.Postgresql()  # Lanuch new PostgreSQL server

# connect to PostgreSQL
from sqlalchemy import create_engine
engine = create_engine(postgresql.url())

# if you use postgresql or other drivers:
#   import psycopg2
#   db = psycopg2.connect(**postgresql.dsn())

#
# do any tests using PostgreSQL...
#

del postgresql                     # Terminate PostgreSQL server

testing.postgresql.Postgresql executes initdb and postmaster on instantiation. On deleting Postgresql object, it terminates PostgreSQL instance and removes temporary directory.

If you want a database including tables and any fixtures for your apps, use copy_data_from keyword:

# uses a copy of specified data directory of PostgreSQL.
postgresql = testing.postgresql.Postgresql(copy_data_from='/path/to/your/database')

You can specify parameters for PostgreSQL with my_cnf keyword:

# boot PostgreSQL server without socket listener (use unix-domain socket)
postgresql = testing.postgresql.Postgresql(my_cnf={'skip-networking': None})

For example, you can setup new PostgreSQL server for each testcases on setUp() method:

import unittest
import testing.postgresql

class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.postgresql = testing.postgresql.Postgresql(my_cnf={'skip-networking': None})

Requirements

  • Python 2.7, 3.3

  • psycopg2

License

Apache License 2.0

History

1.0.0 (2013-12-04)

  • Add @skipIfNotFound decorator

0.1.0 (2013-11-26)

  • First release

Metadata

Release files for testing.postgresql 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for testing.postgresql 1.0.0
File Size Uploaded Provenance Actions
testing.postgresql-1.0.0.tar.gz 9.0 kB Without provenance Details for testing.postgresql-1.0.0.tar.gz

Release files / testing.postgresql-1.0.0.tar.gz

Download URL testing.postgresql-1.0.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e41f6360967b3878fd20ee212e85797d8aaa4e8c3bce4a60997a1bd929bd2ca6
BLAKE2b-256 checksum
How to use checksums
4e74e6e3b8dbe7af0d8710a111adf0fdbfbb4704860dfe2aba418e83a24ed8f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for testing.postgresql 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page