Re: RFC: adding pytest as a supported test framework

From: "Jelte Fennema-Nio" <postgres(at)jeltef(dot)nl>
To: "Andres Freund" <andres(at)anarazel(dot)de>
Cc: "Jacob Champion" <jacob(dot)champion(at)enterprisedb(dot)com>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Daniel Gustafsson" <daniel(at)yesql(dot)se>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Peter Eisentraut" <peter(at)eisentraut(dot)org>, "Nazir Bilal Yavuz" <byavuz81(at)gmail(dot)com>
Subject: Re: RFC: adding pytest as a supported test framework
Date: 2025-12-18 10:27:05
Message-ID: DF19RFCXY2T2.2A3BWV18NC2HL@jeltef.nl
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 17 Dec 2025 at 17:10, Andres Freund <andres(at)anarazel(dot)de> wrote:
> I assume this intentionally doesn't pass CI:
> https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F6045

Yeah it was, but turns out was also actually broken because of that.
Attached is a new version that actually passes all tests. It also adds
logic to convert postgres errors into python exceptions. I also moved
the commits around a bit, so the SSL tests from Jacob are now built on
top of my improvements to the test infra.

> Why do we need pytest the program at all? Running the tests one-by-one with
> pytest as a runner doesn't seem to make a whole lot of sense to me.

Do you mean use "python -m pytest" instead of "pytest"?

Or do you mean running python files manually somehow? Because that's not
possible. There's only functions defined in those test files, they're
not executable by themselves. pytest is still needed to find those in
each file, as well as the fixtures they require. And ofcourse to make
assertion errors show up as nicely.

> I think it'd be a seriously bad idea to start with no central infrastructure,
> we'd be force to duplicate that all over. Eventually we'll be forced to
> introduce some central infrastructure, but we'll probably not go around and
> carefully go through the existing tests for stuff that should now use the
> common infrastructure.

The infra to do query execution on a single postgres server is there
(patch 0004). That one seemed the most important to me. I'm currently
still working on some infrastructure to be able to spawn multiple
postgres servers (I'm validating that by converting the libpq load
balance TAP tests that I wrote in the past). Is there other
infrastructure that you think is needed?

Attachment Content-Type Size
v4-0001-meson-Include-TAP-tests-in-the-configuration-summ.patch text/x-patch 1.1 KB
v4-0002-Add-support-for-pytest-test-suites.patch text/x-patch 35.3 KB
v4-0003-ci-Add-MTEST_SUITES-for-optional-test-tailoring.patch text/x-patch 3.1 KB
v4-0004-Add-pytest-infrastructure-to-interact-with-Postgr.patch text/x-patch 120.0 KB
v4-0005-WIP-pytest-Add-some-SSL-client-tests.patch text/x-patch 19.4 KB
v4-0006-WIP-pytest-Add-some-server-side-SSL-tests.patch text/x-patch 9.6 KB
v4-0007-XXX-run-pytest-and-ssl-suite-all-OSes.patch text/x-patch 1.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2025-12-18 10:34:49 RE: Parallel Apply
Previous Message Shixin Wang 2025-12-18 10:26:55 Re: Fix wrong reference in pg_overexplain's doc