Skip to main content

About

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

https://travis-ci.org/tk0miya/testing.postgresql.svg?branch=master https://coveralls.io/repos/tk0miya/testing.postgresql/badge.png?branch=master https://codeclimate.com/github/tk0miya/testing.postgresql/badges/gpa.svg
Documentation

https://github.com/tk0miya/testing.postgresql

Issues

https://github.com/tk0miya/testing.postgresql/issues

Download

https://pypi.python.org/pypi/testing.postgresql

Install

Use pip:

$ pip install testing.postgresql

And testing.postgresql requires PostgreSQL server in your PATH.

Usage

Create PostgreSQL instance using testing.postgresql.Postgresql:

import testing.postgresql
from sqlalchemy import create_engine

# Lanuch new PostgreSQL server
with testing.postgresql.Postgresql() as postgresql:
    # connect to PostgreSQL
    engine = create_engine(postgresql.url())

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

    #
    # do any tests using PostgreSQL...
    #

# PostgreSQL server is terminated here

testing.postgresql.Postgresql executes initdb and postgres 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')

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()

    def tearDown(self):
        self.postgresql.stop()

Requirements

  • Python 2.6, 2.7, 3.2, 3.3, 3.4

  • pg8000 1.10

License

Apache License 2.0

History

1.2.1 (2015-08-22)

  • Fix bug:

    • Close #3 Fix AttributeError on end of tests

1.2.0 (2015-05-17)

  • Use pg8000 for connector to create test database

  • Connect to postgres to create test database (instead of template1)

1.1.2 (2015-04-06)

  • Fix bugs:

    • Do not call os.getpid() on destructor (if not needed)

    • Raise detailed RuntimeError if initdb exits non-zero

1.1.1 (2015-01-18)

  • Disable logging_collector feature (For Fedora)

  • Fix bugs:

    • MacPorts default path is /opt/local/lib/postgresql*, no dash

1.1.0 (2014-12-20)

  • Invoke ‘postgres’ command instead of ‘postmaster’

1.0.6 (2014-07-19)

  • Fix #1 Dirty postmaster shut down

1.0.5 (2014-07-19)

  • Fix path for PostgreSQL

  • Use absolute path for which command

1.0.4 (2014-06-19)

  • Fix timeout on terminating postgresql

  • Support PostgreSQL on /usr/local/bin (cf. FreeBSD ports)

  • Fix bugs

1.0.3 (2014-06-11)

  • Fix ImportError if caught SIGINT on py3

1.0.2 (2013-12-06)

  • Change behavior: Postgresql#stop() cleans workdir

  • Fix caught AttributeError on object deletion

1.0.1 (2013-12-05)

  • Add @skipIfNotInstalled decorator (alias of skipIfNotFound)

  • Suport python 2.6 and 3.2

1.0.0 (2013-12-04)

  • Add @skipIfNotFound decorator

0.1.0 (2013-11-26)

  • First release

Metadata

Release files for testing.postgresql 1.2.1

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.2.1
File Size Uploaded Provenance Actions
testing.postgresql-1.2.1.tar.gz 11.2 kB Without provenance Details for testing.postgresql-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for testing.postgresql 1.2.1
File Interpreter ABI Platform Actions
testing.postgresql-1.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for testing.postgresql-1.2.1-py2.py3-none-any.whl

Total release size: 20.1 kB

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

Download URL testing.postgresql-1.2.1.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6d9fe894e101d28a824d66a913427fa1ebe37699cb6e43c12e1a99c1e7b27634
BLAKE2b-256 checksum
How to use checksums
104c8886f4a5db9ca9bc360dd781b6374733b9fdd2dda8d3809278b203a74c24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / testing.postgresql-1.2.1-py2.py3-none-any.whl

Download URL testing.postgresql-1.2.1-py2.py3-none-any.whl
Size 8.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4a29b61dc624a53a672367034a3017e3bc7cb2258bbccdd7da958c14335fb2ef
BLAKE2b-256 checksum
How to use checksums
7bd4c372319d521ee7415fc57423c33561672a7c4a471dea7c60f24e87fe049d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for testing.postgresql 1.2.1

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