Skip to content

Commit 059e4bc

Browse files
committed
Refactor PostgreSQLExecutor to support Windows compatibility for process management
- Convert _get_base_command method to BASE_PROC_START_COMMAND class attribute - Use unified command format without single quotes around PostgreSQL config values - Add _windows_terminate_process method for graceful Windows process termination - Update stop() method to use list args instead of shell=True for security - Add platform-specific termination logic with killpg fallback - Add comprehensive Windows compatibility test suite - Merge latest changes from main branch
1 parent 7c17701 commit 059e4bc

36 files changed

+514
-85
lines changed

.github/workflows/automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
automerge:
16-
uses: fizyk/actions-reuse/.github/workflows/shared-automerge.yml@v4.1.1
16+
uses: fizyk/actions-reuse/.github/workflows/shared-automerge.yml@v4.2.1
1717
secrets:
1818
app_id: ${{ secrets.MERGE_APP_ID }}
1919
private_key: ${{ secrets.MERGE_APP_PRIVATE_KEY }}

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ on:
88

99
jobs:
1010
build:
11-
uses: fizyk/actions-reuse/.github/workflows/shared-pypi.yml@v4.1.1
11+
uses: fizyk/actions-reuse/.github/workflows/shared-pypi.yml@v4.2.1

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ on:
99

1010
jobs:
1111
pre-commit:
12-
uses: fizyk/actions-reuse/.github/workflows/shared-pre-commit.yml@v4.1.1
12+
uses: fizyk/actions-reuse/.github/workflows/shared-pre-commit.yml@v4.2.1

.github/workflows/pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- v*
66
jobs:
77
build-n-publish:
8-
uses: fizyk/actions-reuse/.github/workflows/shared-pypi.yml@v4.1.1
8+
uses: fizyk/actions-reuse/.github/workflows/shared-pypi.yml@v4.2.1
99
with:
1010
publish: true
1111
secrets:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
- id: debug-statements
2626

2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.14.11
28+
rev: v0.14.14
2929
hooks:
3030
- id: ruff-check
3131
args: [--fix, --exit-non-zero-on-fix, --respect-gitignore, --show-fixes]

CHANGES.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,66 @@ CHANGELOG
33

44
.. towncrier release notes start
55
6+
pytest-postgresql 8.0.0 (2026-01-23)
7+
====================================
8+
9+
Breaking changes
10+
----------------
11+
12+
- Refactor ``DatabaseJanitor`` to use explicit template management. This includes a new ``as_template`` flag and making ``dbname`` a required parameter. (`#890 <https://github.com/dbfixtures/pytest-postgresql/issues/890>`__)
13+
- Bump the minimum supported pytest version to 8.2.
14+
15+
The previous minimum was about two years old, and older pytest versions
16+
can be flaky with fixture chaining that relies on `getfixturevalue` on
17+
Python 3.12-3.13 when used alongside xdist. (`#890 <https://github.com/dbfixtures/pytest-postgresql/issues/890>`__)
18+
- Support only PostgreSQL version 14 and up. (`#1250 <https://github.com/dbfixtures/pytest-postgresql/issues/1250>`__)
19+
- Dropped support for Python 3.9 as it has reached End of Life
20+
21+
22+
Bugfixes
23+
--------
24+
25+
- Fix issue where `--postgresql-drop-test-database` was applied in process fixture.
26+
27+
It was already being read in client and noprocess fixtures. (`#1148 <https://github.com/dbfixtures/pytest-postgresql/issues/1148>`__)
28+
29+
30+
Documentation
31+
-------------
32+
33+
- Add a Mermaid sequence diagram to the documentation to illustrate fixture chaining and hierarchical cloning. (`#890 <https://github.com/dbfixtures/pytest-postgresql/issues/890>`__)
34+
- Improve code examples by adding types (`#1233 <https://github.com/dbfixtures/pytest-postgresql/issues/1233>`__)
35+
- Add plugins' architecture diagram and display it in project's README. (`#1244 <https://github.com/dbfixtures/pytest-postgresql/issues/1244>`__)
36+
- Improved README.rst:
37+
- Added a "Quick Start" section with a simple example.
38+
- Clarified `psycopg` 3 requirement for the plugin vs. `psycopg` 2 support for the application.
39+
- Updated PostgreSQL versioning notes (>= 10).
40+
- Explained the binary discovery mechanism (`pg_config` vs. fallbacks).
41+
- Promoted `DatabaseJanitor` as an advanced API.
42+
- Fixed broken table layouts and corrected various typos.
43+
44+
45+
Features
46+
--------
47+
48+
- Add ``depends_on`` parameter to ``postgresql_noproc`` factory to allow hierarchical cloning and chaining of process fixtures. (`#890 <https://github.com/dbfixtures/pytest-postgresql/issues/890>`__)
49+
- Convert Config kept in TypedDict into a dataclass (`#1225 <https://github.com/dbfixtures/pytest-postgresql/issues/1225>`__)
50+
- Marked support for Python 3.14
51+
52+
53+
Miscellaneus
54+
------------
55+
56+
- `#1127 <https://github.com/dbfixtures/pytest-postgresql/issues/1127>`__, `#1218 <https://github.com/dbfixtures/pytest-postgresql/issues/1218>`__
57+
- Add new release workflow, which will allow releasing new versions directly from GitHub.
58+
- Drop PostgreSQL 13 and add PostgreSQL 18 to the CI
59+
- Update github-actions for actions-reuse 4.x
60+
- Updates to pre-commit
61+
62+
Replaced black with ruff-format, Added https://github.com/fizyk/pyproject-validator,
63+
Moved mypy configuration into pyproject.toml, extended line length to 120 characters.
64+
65+
666
7.0.2 (2025-05-17)
767
==================
868

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "pypi"
77
pytest = "==9.0.2"
88
port-for = "==1.0.0"
99
mirakuru = "==3.0.1"
10-
packaging = "==25.0"
10+
packaging = "==26.0"
1111
psycopg = "==3.3.2"
1212

1313
[dev-packages]
@@ -17,5 +17,5 @@ pytest-cov = "==7.0.0"
1717
pytest-xdist = "==3.8.0"
1818
mock = "==5.2.0"
1919
mypy = {version = "==1.19.1", markers="implementation_name == 'cpython'"}
20-
types-setuptools = "==80.9.0.20251223"
20+
types-setuptools = "==80.10.0.20260124"
2121
tbump = "==6.11.0"

README.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,33 @@ To connect to an external server (e.g., running in Docker), use the ``postgresql
146146
147147
By default, it connects to ``127.0.0.1:5432``.
148148

149+
Chaining fixtures
150+
-----------------
151+
152+
You can chain multiple ``postgresql_noproc`` fixtures to layer your data pre-population. Each fixture in the chain will create its own template database based on the previous one.
153+
154+
.. code-block:: python
155+
156+
from pytest_postgresql import factories
157+
158+
# 1. Start with a process or a no-process base
159+
base_proc = factories.postgresql_proc(load=[load_schema])
160+
161+
# 2. Add a layer with some data
162+
seeded_noproc = factories.postgresql_noproc(depends_on="base_proc", load=[load_data])
163+
164+
# 3. Add another layer with more data
165+
more_seeded_noproc = factories.postgresql_noproc(depends_on="seeded_noproc", load=[load_more_data])
166+
167+
# 4. Use the final layer in your test
168+
client = factories.postgresql("more_seeded_noproc")
169+
170+
171+
172+
.. image:: https://raw.githubusercontent.com/dbfixtures/pytest-postgresql/main/docs/images/architecture_chaining.svg
173+
:alt: Fixture Chaining Diagram
174+
:align: center
175+
149176
Configuration
150177
=============
151178

docs/architecture_chaining.mmd

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
sequenceDiagram
2+
participant Test as Test
3+
participant ProcF as base_proc Fixture
4+
participant NoProc1 as seeded_noproc Fixture
5+
participant NoProc2 as more_seeded_noproc Fixture
6+
participant DB as PostgreSQL DB
7+
8+
Test->>ProcF: request base_proc
9+
ProcF->>DB: init database & run load_schema
10+
ProcF-->>Test: return PostgreSQLExecutor
11+
12+
Test->>NoProc1: request seeded_noproc (depends_on=base_proc)
13+
NoProc1->>ProcF: read connection/template info
14+
NoProc1->>DB: create layered DB / run load_data
15+
NoProc1-->>Test: return NoopExecutor
16+
17+
Test->>NoProc2: request more_seeded_noproc (depends_on=seeded_noproc)
18+
NoProc2->>NoProc1: read connection/template info
19+
NoProc2->>DB: run load_more_data on layered DB
20+
NoProc2-->>Test: return NoopExecutor
21+
22+
Test->>Test: validate tables and data across layers

newsfragments/+3cf1375f.docs.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)