Re: RFC: adding pytest as a supported test framework
Jelte Fennema-Nio <postgres@jeltef.nl>
From: "Jelte Fennema-Nio" <postgres@jeltef.nl>
To: "Andres Freund" <andres@anarazel.de>
Cc: "Jacob Champion" <jacob.champion@enterprisedb.com>, "PostgreSQL Hackers"
<pgsql-hackers@postgresql.org>, "Robert Haas" <robertmhaas@gmail.com>,
"Daniel Gustafsson" <daniel@yesql.se>, "Tom Lane" <tgl@sss.pgh.pa.us>,
"Peter Eisentraut" <peter@eisentraut.org>, "Nazir Bilal Yavuz"
<byavuz81@gmail.com>
Date: 2025-12-18T10:27:05Z
Lists: pgsql-hackers
Attachments
- v4-0001-meson-Include-TAP-tests-in-the-configuration-summ.patch (text/x-patch)
- v4-0002-Add-support-for-pytest-test-suites.patch (text/x-patch)
- v4-0003-ci-Add-MTEST_SUITES-for-optional-test-tailoring.patch (text/x-patch)
- v4-0004-Add-pytest-infrastructure-to-interact-with-Postgr.patch (text/x-patch)
- v4-0005-WIP-pytest-Add-some-SSL-client-tests.patch (text/x-patch)
- v4-0006-WIP-pytest-Add-some-server-side-SSL-tests.patch (text/x-patch)
- v4-0007-XXX-run-pytest-and-ssl-suite-all-OSes.patch (text/x-patch)
On Wed, 17 Dec 2025 at 17:10, Andres Freund <andres@anarazel.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?