Re: RFC: adding pytest as a supported test framework
Jelte Fennema-Nio <postgres@jeltef.nl>
From: "Jelte Fennema-Nio" <postgres@jeltef.nl>
To: "Jacob Champion" <jacob.champion@enterprisedb.com>
Cc: "PostgreSQL Hackers" <pgsql-hackers@postgresql.org>, "Robert Haas"
<robertmhaas@gmail.com>, "Daniel Gustafsson" <daniel@yesql.se>, "Andres
Freund" <andres@anarazel.de>, "Tom Lane" <tgl@sss.pgh.pa.us>, "Peter
Eisentraut" <peter@eisentraut.org>, "Nazir Bilal Yavuz"
<byavuz81@gmail.com>
Date: 2025-10-22T12:44:15Z
Lists: pgsql-hackers
Attachments
- v3-0001-meson-Include-TAP-tests-in-the-configuration-summ.patch (text/x-patch) patch v3-0001
- v3-0002-Add-support-for-pytest-test-suites.patch (text/x-patch) patch v3-0002
- v3-0003-WIP-pytest-Add-some-SSL-client-tests.patch (text/x-patch) patch v3-0003
- v3-0004-WIP-pytest-Add-some-server-side-SSL-tests.patch (text/x-patch) patch v3-0004
- v3-0005-ci-Add-MTEST_SUITES-for-optional-test-tailoring.patch (text/x-patch) patch v3-0005
- v3-0006-XXX-run-pytest-and-ssl-suite-all-OSes.patch (text/x-patch) patch v3-0006
- v3-0007-Refactor-and-improve-pytest-infrastructure.patch (text/x-patch) patch v3-0007
On Mon, 22 Sept 2025 at 22:30, Jacob Champion <jacob.champion@enterprisedb.com> wrote:
> Done this way in v2-0002
Okay I finally managed to do some testing of this patchset while working
on a patchset of mine where I'm adding a GoAway message to the protocol
(should be ready to be published soon)
First of all: THANK YOU! It's a great base to start from and I hope we
can relatively soon have something merged, that we can gradually
improve.
I had some problems using it for my own tests though. The primary
reasons for that were:
1. It was missing functionality to send queries and get results.
2. A lot of the fixtures I wanted to use were located in the ssl tests
directory instead of the shared fixtures module.
3. When running pytest manually I had to configure LD_LIBRARY_PATH
So here's your patchset with an additional commit on top that does a
bunch of refactoring/renaming and adding features. I hope you like it. I
tried to make the most common actions easy to do.
The primary features it adds are:
- A `sql` method on `PGconn`: It takes a query and returns the results
as native python types.
- A `conn` fixture: Which is a libpq based connection to the default
Postgres server.
- Use the `pg_config` binary to find the libdir and bindir (can be
overridden by setting PG_CONFIG). Otherwise I had to use
LD_LIBRARY_PATH when running pytest manually.
The refactoring it does:
- Rename `pg_server` fixture to `pg` since it'll likely be one of the
most commonly used ones.
- Rename `pg` module to `pypg` to avoid naming conflict/shadowing
problems with the newly renamed `pg` fixture
- Move class definitions outside of fixtures to separate modules (either
in the `pypg` module or the new `libpq` module)
- Move all "general" fixtures to the `pypg.fixtures` module, instead of
having them be defined in the ssl module.