Re: RFC: adding pytest as a supported test framework

From: "Jelte Fennema-Nio" <postgres(at)jeltef(dot)nl>
To: "Jacob Champion" <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Daniel Gustafsson" <daniel(at)yesql(dot)se>, "Andres Freund" <andres(at)anarazel(dot)de>, "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-10-22 12:44:15
Message-ID: DDOUZE2TCU8O.89TN0AS4GLP7@jeltef.nl
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 22 Sept 2025 at 22:30, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)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.

Attachment Content-Type Size
v3-0001-meson-Include-TAP-tests-in-the-configuration-summ.patch text/x-patch 1.0 KB
v3-0002-Add-support-for-pytest-test-suites.patch text/x-patch 35.9 KB
v3-0003-WIP-pytest-Add-some-SSL-client-tests.patch text/x-patch 35.2 KB
v3-0004-WIP-pytest-Add-some-server-side-SSL-tests.patch text/x-patch 29.3 KB
v3-0005-ci-Add-MTEST_SUITES-for-optional-test-tailoring.patch text/x-patch 3.1 KB
v3-0006-XXX-run-pytest-and-ssl-suite-all-OSes.patch text/x-patch 1.4 KB
v3-0007-Refactor-and-improve-pytest-infrastructure.patch text/x-patch 74.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-10-22 12:59:02 Re: Stack-based tracking of per-node WAL/buffer usage
Previous Message Nazir Bilal Yavuz 2025-10-22 12:33:37 Re: Speed up COPY FROM text/CSV parsing using SIMD