NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #2008 most downloaded on PyPI
Postgresql fixtures and fixture factories for Pytest.
Last release today
04 Oct 2026
Release timing varies
gaps range from 3 weeks to 8 months
Nearly every release is documented
notes for 47 of 50 stable releases
Nothing withdrawn
no release was ever pulled
10 years old
50 releases · first in 2016
Nothing published for this version
pg_ctl discovery now finds a Windows PostgreSQL install without --postgresql-exec. The default executable path is empty on Windows, and discovery prob
pg_ctl discovery now finds a Windows PostgreSQL install without --postgresql-exec. The default executable path is empty on Windows, and discovery probes %ProgramFiles%\PostgreSQL\*\bin\pg_ctl.exe (newest version first) and PATH after pg_config --bindir. (#1399)
Migrate tests to be based on actions-reuse new composite action uv-pytest-coverage (#1424)
One column per quarter.
Deprecated the unused version argument of DatabaseJanitor and AsyncDatabaseJanitor. (#1393 __)
Load functions passed to proc/noproc fixtures have to accept new autocommit argument. (#902)
postgresql_noproc has an additional parameter load_autocommit which is grouped together with load making positional arguments filled till depends_on incompatible. (#902)
Arguments after dbname in postgresql_noproc are now keyword-only. Update callers that pass options, load, load_autocommit or depends_on positionally. (#1387)
Arguments after dbname in postgresql_proc are now keyword-only. Update callers that pass options, startparams, unixsocketdir, postgres_options, load or load_autocommit positionally. (#1387)
Arguments after dbname in PostgreSQLExecutor. Update callers that pass +`shell`, timeout, sleep, user, password, +`options`, or postgres_options positionally. (#1387)
Deprecated the unused version argument of DatabaseJanitor and AsyncDatabaseJanitor. (#1393)
The database used to create/drop test databases and read the server version is no longer hardcoded to postgres. Set it with the postgresql_maintenance_dbname ini option, the --postgresql-maintenance-dbname command line option, or the maintenance_dbname argument of factories.postgresql_noproc and DatabaseJanitor/AsyncDatabaseJanitor. Defaults to postgres. (#653)
Allow running the SQL loader connection with autocommit enabled, so .sql files containing statements that cannot run inside a transaction block (such as CREATE DATABASE) can be loaded. This is configurable without a custom loader in three ways: the postgresql_load_autocommit ini option, the --postgresql-load-autocommit command line flag, or the load_autocommit argument of the postgresql_proc / postgresql_noproc factories (which also maps to an autocommit argument on DatabaseJanitor / AsyncDatabaseJanitor). (#902)
Added async PostgreSQL fixture support via postgresql_async factory and AsyncDatabaseJanitor. Added optional async extra (pip install pytest-postgresql[async]) providing pytest-asyncio (>= 1.4) and aiofiles dependencies. (#1235)
pg_ctl discovery no longer hands back a path that does not exist. A client-only PostgreSQL install (Debian/Ubuntu's libpq-dev without the matching server package) makes pg_config --bindir point at a directory holding no pg_ctl; that path used to be returned unchecked, and the failure only surfaced later as Could not found ... when the executor read the server version. The path is now verified up front, and the ExecutableMissingException names the locations that were checked along with the ways to fix it: install the server package, point at a pg_ctl with --postgresql-exec, or use postgresql_noproc against a server you run yourself.
A broken pg_config is reported the same way. Only FileNotFoundError used to be handled, so a non-executable or failing pg_config escaped as a raw PermissionError/CalledProcessError. (#1031)
Fixed DeprecationWarning on Python 3.14 from deprecated asyncio event-loop policy usage on Windows; use pytest-asyncio loop factories instead. (#1295)
Corrected the README's description of how pg_ctl is located — it listed the discovery steps in the wrong order — and spelled out that postgresql_proc needs a local PostgreSQL server, pointing at postgresql_noproc for dockerised or otherwise externally managed servers. (#1031)
Pin GitHub Actions to immutable commit SHAs (#1331)
Enabled Ruff's FBT rules to detect boolean positional arguments. (#1387)
postgresql_proc now tears down through a fixture yield instead of request.addfinalizer. Consuming it as a pytest fixture is unaffected. (#1397)
Enabled Ruff's PT rules to keep pytest usage consistent across the plugin and its test suite. (#1397)
Gathered all executors under common executors package. (#1402)
Add release-schedule workflow replacing manual release workflow. (#1410)
Migrated the Automerge workflow to fizyk/actions-reuse version 5.5.0. (#1411)
Add actionlint to pre-commit (#1414)
Configure Dependabot to update pre-commit dependencies. (#1415)
Add Python 3.15 to CI
Add pyproject-fmt to pre-commit tools.
Add zizmor to pre-commit and harden GitHub Actions workflow permissions.
Deduplicate DatabaseJanitor codebase after async introduction.
Extended coderabbit configuration
Migrate developer environment from pipenv to uv
Scope the test_postgres_terminate_connection (and async) connection check to the test's own database via datname = current_database().
So a transient, already-closed janitor connection on the postgres maintenance database no longer causes spurious timeouts on macOS CI.
Set CodeRabbit review profile to assertive for stricter pull request reviews.
Update automerge to new 5.x version and change app id to client id
Add Windows support for PostgreSQLExecutor, including platform-specific start/stop handling. (#1182 __)
Add Windows support for PostgreSQLExecutor, including platform-specific start/stop handling. (#1182)
Make sure diagrams are using unified terminology.
Fix typos (#1267)
Add pytest-postgresql as an editable self-install in the Pipfile; remove the manual from pytest_postgresql.plugin import * import from tests/conftest.py and the makeconftest call in tests/test_postgres_options_plugin.py that re-registered the plugin and caused duplicate-plugin errors under editable install.
Add coderabbitai configuration with instructions to keep an eye for newsfragments.
Attempt to overcome random failure on CI on MacOS on xdist workers where test_executor_init_with_password is receiving FATAL: the database system is starting up error message from psycopg.
That's the only test that doesn't have guards against attempting to start on the same port as other xdist worker.
Fix codecov pipeline configuration.
Fixes for diagram workflow.
Improve reliability of Coverage reporting on CI
Migrate package publishing step to trusted publishing.
Refactor DatabaseJanitor to use explicit template management. This includes a new as_template flag and making dbname a required parameter. (#890 __)
Refactor DatabaseJanitor to use explicit template management. This includes a new as_template flag and making dbname a required parameter. (#890)
Bump the minimum supported pytest version to 8.2.
The previous minimum was about two years old, and older pytest versions can be flaky with fixture chaining that relies on getfixturevalue on Python 3.12-3.13 when used alongside xdist. (#890)
Support only PostgreSQL version 14 and up. (#1250)
Dropped support for Python 3.9 as it has reached End of Life
Fix issue where --postgresql-drop-test-database was applied in process fixture.
It was already being read in client and noprocess fixtures. (#1148)
Add a Mermaid sequence diagram to the documentation to illustrate fixture chaining and hierarchical cloning. (#890)
Improve code examples by adding types (#1233)
Add plugins' architecture diagram and display it in project's README. (#1244)
Improved README.rst: - Added a "Quick Start" section with a simple example. - Clarified psycopg 3 requirement for the plugin vs. psycopg 2 support for the application. - Updated PostgreSQL versioning notes (>= 10). - Explained the binary discovery mechanism (pg_config vs. fallbacks). - Promoted DatabaseJanitor as an advanced API. - Fixed broken table layouts and corrected various typos.
Add depends_on parameter to postgresql_noproc factory to allow hierarchical cloning and chaining of process fixtures. (#890)
Convert Config kept in TypedDict into a dataclass (#1225)
Marked support for Python 3.14
Add new release workflow, which will allow releasing new versions directly from GitHub.
Drop PostgreSQL 13 and add PostgreSQL 18 to the CI
Update github-actions for actions-reuse 4.x
Updates to pre-commit
Replaced black with ruff-format, Added https://github.com/fizyk/pyproject-validator, Moved mypy configuration into pyproject.toml, extended line length to 120 characters.
Fix an issue where number of search counts has been hard-default set to 5 by command-line default and ini setting could not override it. (#1115 __)
Fix an issue where number of search counts has been hard-default set to 5 by command-line default and ini setting could not override it. (#1115)
Update minimum required pytest version to 7.2
Additionally added test run of pytest-postgresql against oldest supported versions. (#1131)
Different approach to oldest requirements file. Trying to get dependabot off of it.
Test pipeline optimisations
Close postgresql connection after loading sql files.
Close postgresql connection after loading sql files.
Fixes possible ResourceWarning
Fixed an issue, where defining load paths in ini/toml configuration would fail due to pytest's LocalPath not having an endswith method.
In Python 3.13, usage of a positional argument for maxsplit has been formally deprecated. Update code to use keyword argument maxsplit instead of posi…
Drop support for load parameter from client fixtures. This can be easily replaced by creating intermediary fixture between test and client fixture. (#1087)
Stop supporting Python 3.8 as it already reached EOL
Passing all environment variables to the initdb.
This helps the cases where og_ctl is replaced by custom shell script making additional calls, and needs all the variables, that ie server process gets. (#1076)
If a test run ended in an error that prevented proper test cleanup, developer can now use --postgresql-drop-test-database command line flag, to delete database from noproc fixture at the start. (#265)
DatabaseJanitor.cursor now accepts optional parameter dbname, which defaults to postgres
This database name is used to make connection to and return a cursor. (#265)
When running tests with xdist, pytest-postgresql now attempts to detect random ports selected by other nodes by writing down a .port file in session temporary directory.
The number of tries it attempts to select unused port is configurable, and defaults to 0.
In case pytest-postgresql won't be able to select unused port, PortForException is thrown with appropriate message. (#872)
Mark Python 3.13 as supported.
Add PostgreSQL 17 to CI and drop 12
Add [bot] suffix to the pre-commit actor.
Adjust links after repository transfer
Adjust workflows for actions-reuse 3.0.1
Fix DatabaseJanitor documentation.
In Python 3.13, usage of a positional argument for maxsplit has been formally deprecated. Update code to use keyword argument maxsplit instead of positional.
Skip local hooks from ci
Skip newsfragment checks for pre-commit actor.
Update pre-commit configuration to use ruff instead of flake8/pydocstyle
Set minimum version of port-for dependecy in pyproject.toml for client installations. (#1015 __)
Set minimum version of port-for dependecy in pyproject.toml for client installations. (#1015)
add support for \\ character in pytest temporary path (#982 __)
Fixed a long-standing bug, where calls to pg_ctl weren't getting LC_* and LANG envvars, which caused issues on some systems not recognizing --auth par
Deprecated load parameter on a client fixture. Developers are encouraged to either use the load function/parameter for process fixture, or create an i…
DatabaseJanitor class now accepts only keyword arguments. (#899)
Fix the remaining DepcrecationWarning for datetime.datetime.utcnow on Python 3.12. (#896)
Deprecated load parameter on a client fixture. Developers are encouraged to either use the load function/parameter for process fixture, or create an intermediate fixture placed between client and tests themselves to fill in the data. (#850)
Now all sql files used to initialise database for tests, has to be passed as pathlib.Path instance.
This helps the DatabaseJanitor choose correct behaviour based on parameter. (#638)
Have separate parameters for template database name and database name in DatabaseJanitor. It'll make it much clearer to understand the code and Janitor's behaviour. (#672)
Template databases are now created with is_template flag turned on, and not by setting allow_connections to false.
The allow_connections flag being set to false is used strictly right before we attempt to drop the database. (#914)
Add missing python 3.12 classifier to pythin package. (#915 __)
Add missing python 3.12 classifier to pythin package. (#915)
Update postgresql_load default value for it to fallback into the empty list (#881 __)
Update postgresql_load default value for it to fallback into the empty list (#881)
Support for Python 3.12 (#835)
Removed misleading parapgraph from one example in a README (#688)
Fixed typing exceptions for mypy 1.4 (#765)
Add SQLAlchemy example for initialising common database state. (#797)
Rely on cached/artifacted Pipfile.lock. That way, it will be specifically defined for given python version/system. (#834)
CI Change - Add PostgreSQL 16, drop PostgreSQL 11 (#836)
Replace usage of pkg_resources.parse_version with packaging.version.parse (#858)
Drop support for Python 3.7 (#706 __)
Drop support for Python 3.7 (#706)
psycopg is now a mandatory requirement. With pyscop2 it was optional due to the different ways it could be installed:
psycopg2 - that built itself
psycopg2-binary - binary distribution
psycopg2cffi - pypy enabled version
Since psycopg version 3 there's only one package to install. (#744)
Dropped --postgresql-logsprefix/postgresql_logsprefix options. All fixture data is already distinguished by tmpdir itself. (#748)
Drop PyPy from CI (#669)
pytest-postgresql will now recognise and use development postgresql versions (#691)
Use towncrier to maintain project's newsfragments/changelog (#700)
Move project dependency management to pipenv (#701)
Migrate to shared automerge workflow for automatic tests dependency updates (#702)
Use tbump instead of bumpversion to manage versioning and releases. (#703)
Move most of package configuration to pyproject.toml (#704)
Introduce Typed config dict (#706)
Use ankane/setup-postgres@v1 to setup postgresql in CI instead of custom scripts. (#708)
Pass codecov_token to codecov action to upload coverage. (#721)
Replaced flake8 and pydocstyle with ruff, turned on isort rules (#735)
Split single bid test job into smaller running each after another. (#740)
Docker documentation example typo fixes
Error message typo fix
Docker documentation example typo fixes
Have setuptools required as package dependency. pkg_resources.parse_version is used in code but setuptools was only used as build requirements
Import FixtureRequest from pytest, not private _pytest. Require at least pytest 6.2
Import FixtureRequest from pytest, not private _pytest. Require at least pytest 6.2
Replace tmpdir_factory with tmp_path_factory
Xdist running test connecting to already existing postgresql, will now create separate databases for each worker.
Upgrade to psycopg 3.
Xdist running test connecting to already existing postgresql, will now create separate databases for each worker.
Use psycopg 3 and return its connections in client fixtures.
Drop support for postgresql 9.6
client fixture will no longer utilize configuration's load param
client fixture will no longer utilize configuration's dbanme parameter
Add Postgresql 14 to the CI
Nothing published for this version
Database can be created by DatabaseJanitor or the client fixture when an isolation level is specified.
Database can be created by DatabaseJanitor or the client fixture when an isolation level is specified.
rely on get_port functionality delivered by port_for
rely on get_port functionality delivered by port_for
Added type annotations and compatibitlity with PEP 561
Added type annotations and compatibitlity with PEP 561
pre-commit configuration
Changed UPDATE pg_database SET to ALTER. System tables should not be updated.
Changed UPDATE pg_database SET to ALTER. System tables should not be updated.
Fixed DatabaseJanitor port type hint to int from str
Fixed DatabaseJanitor port type hint to int from str
Changed retry definition to not fail if psycopg2 is not installed. Now the default is Exception.
Support python 3.7 and up
Deprecated support for logs_prefix process fixture factory argument, --postgresql-logsprefix pytest command line option and postgresql_logsprefix ini…
Ability to create template database once for the process fixture and re-recreate a clean database out of it every test. Not only it does provide some common db initialisation between tests but also can speed up tests significantly, especially if the initialisation has lots of operations to perform.
DatabaseJanitor can now define a connection_timeout parameter. How long will it try to connect to database before raising a TimeoutError
Updated supported python versions
Unified temporary directory handling in fixture. Settled on tmpdir_factory.
Fully moved to the Github Actions as CI/CD pipeline
Deprecated support for logs_prefix process fixture factory argument, --postgresql-logsprefix pytest command line option and postgresql_logsprefix ini configuration option. tmpdir_factory now builds pretty unique temporary directory structure.
Dropped support for postgresql 9.5 and down
Removed init_postgresql_database and drop_postgresql_database functions. They were long deprecated and their role perfectly covered by DatabaseJanitor class.
pytest_postgresql.factories.get_config was moved to pytest_postgresql.config.get_config
all db_name keywords and attributes were renamed to dbname
postgresql_nooproc fixture was renamed to postgresql_noproc
Use postgresql_logsprefix and --postgresql-logsprefix again. They were stopped being used somewhere along the way.
Sometimes pytest-postrgesql would fail to start postgresql with "FATAL: the database system is starting up" message. It's not really a fatal error, but a message indicating that the process still starts. Now pytest-postgresql will wait properly in this cases.
[bugfix] To not fail loading code if no postgresql version is installed. Fallback for janitor and process fixture only, if called upon.
[bugfix] To not fail loading code if no postgresql version is installed. Fallback for janitor and process fixture only, if called upon.
[enhancement] add ability to pass options to pg_ctl's -o flag to send arguments to the underlying postgres executable Use postgres_options as fixture
[enhancement] add ability to pass options to pg_ctl's -o flag to send arguments to the underlying postgres executable Use postgres_options as fixture argument, --postgresql-postgres-options as pytest starting option or postgresql_postgres_options as pytest.ini configuration option
[enhancement] Add ability to set up isolation level for fixture and janitor
[enhancement] Add ability to set up isolation level for fixture and janitor
[fix] Status checks for running postgres depend on pg_ctl status code, not on pg_ctl log language. Fixes starting on systems without C locale. Thanks
[fix] Status checks for running postgres depend on pg_ctl status code, not on pg_ctl log language. Fixes starting on systems without C locale. Thanks @Martin Meyries.
[fix] Added LC_* env vars to running initdb and other utilities. Now all tools and server are using same, C locale
[fix] Added LC_* env vars to running initdb and other utilities. Now all tools and server are using same, C locale
[feature] Ability to define default schema to initialize database with
[feature] Ability to define default schema to initialize database with
[docs] Added more examples to readme on how to use the plugin
[enhancement] extract NoopExecutor into it's own submodule
[enhancement] extract NoopExecutor into it's own submodule
[bugfix] Ignore occasional ProcessFinishedWithError error on executor exit.
[bugfix] Fixed setting custom password for process fixture
[bugfix] Fix version detection, to allow for two-digit minor version part
[feature] Drop support for python 3.5
[feature] Drop support for python 3.5
[enhancement] require at least mirakuru 2.3.0 (executor's stop method parameter's change)
[bug] pass password to DatabaseJanitor in client's factory
[feature] Allow to set password for postgresql. Use it throughout the flow.
[feature] Allow to set password for postgresql. Use it throughout the flow.
[bugfix] Default Janitor's connections to postgres database. When using custom users, postgres attempts to use user's database and it might not exist.
[bugfix] NoopExecutor connects to read version by context manager to properly handle cases where it can't connect to the server.
[bugfix] Fix drop_postgresql_database to actually use DatabaseJanitor.drop instead of an init
[bugfix] Fix drop_postgresql_database to actually use DatabaseJanitor.drop instead of an init
[feature] ability to properly connect to already existing postgresql server using postgresql_nooproc fixture.
[feature] ability to properly connect to already existing postgresql server using postgresql_nooproc fixture.
[deprecate] Deprecate init_postgresql_database in favour of DatabaseJanitor.init
[enhancement] Gather helper functions maintaining postgresql database in DatabaseJanitor class.
[deprecate] Deprecate init_postgresql_database in favour of DatabaseJanitor.init
[deprecate] Deprecate drop_postgresql_database in favour of DatabaseJanitor.drop
[feature] Drop support for python 2.7. From now on, only support python 3.5 and up
[feature] Drop support for python 2.7. From now on, only support python 3.5 and up
[feature] Ability to configure database name through plugin options
[enhancement] Use tmpdir_factory. Drop logsdir parameter
[ehnancement] Support only Postgresql 9.0 and up
[bugfix] Always start postgresql with LC_ALL, LC_TYPE and LANG set to C.UTF-8. It makes postgresql start in english.
[bugfix] Allow creating test database with hyphens
[bugfix] Allow creating test database with hyphens
[enhancements] Ability to configure additional options for postgresql process and connection
[enhancements] Ability to configure additional options for postgresql process and connection
[bugfix] - removed hard dependency on psycopg2, allowing any of its alternative packages, like psycopg2-binary, to be used.
[maintenance] Drop support for python 3.4 and use 3.7 instead
[bugfix] properly detect if executor running and clean after executor is being stopped
[bugfix] properly detect if executor running and clean after executor is being stopped
Note
Previously if a test failed, there was a possibility of the executor being removed when python was closing, causing it to print ignored errors on already unloaded modules.
[enhancement] use executor's context manager to start/stop postrgesql server in a fixture
[enhancement] use executor's context manager to start/stop postrgesql server in a fixture
[bugfix] version regexp to correctly catch postgresql 10
[bugfix] version regexp to correctly catch postgresql 10
[enhancement] explicitly turn off logging_collector
[enhancement] explicitly turn off logging_collector
- [feature] pypy compatibility
[feature] pypy compatibility
[bugfix] - disallow connection to database before it gets dropped.
[bugfix] - disallow connection to database before it gets dropped.
Note
Otherwise it caused random test subprocess to connect again and this the drop was unsuccessful which resulted in many more test fails on setup.
[cleanup] - removed path.py dependency
[bugfix] - Fixing the default pg_ctl path creation
[bugfix] - Fixing the default pg_ctl path creation
[feature] - migrate usage of getfuncargvalue to getfixturevalue. require at least pytest 3.0.0
[feature] - migrate usage of getfuncargvalue to getfixturevalue. require at least pytest 3.0.0
create command line and pytest.ini configuration options for postgresql starting parameters
create command line and pytest.ini configuration options for postgresql starting parameters
create command line and pytest.ini configuration options for postgresql username
make the port random by default
create command line and pytest.ini configuration options for executable
create command line and pytest.ini configuration options for host
create command line and pytest.ini configuration options for port
Extracted code from pytest-postgresql
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →