automatically setups a postgresql instance in a temporary directory, and destroys it after testing
Project description
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.6, 2.7, 3.2, 3.3
psycopg2
License
Apache License 2.0
History
1.0.1 (2013-12-05)
Add mysqld.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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file testing.postgresql-1.0.1.tar.gz
.
File metadata
- Download URL: testing.postgresql-1.0.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f33ff40056c11fea6dcb20d1240b0f86a9b0a0b3ad90a458d40b506ddc9f592a |
|
MD5 | d5d48faac9f0c4f2311191b81a4bec0e |
|
BLAKE2b-256 | f5c77c25dcfa40cf1623ca2e65808b96bf676eab2b26561716a3b28dc4714404 |