Re: RFC: adding pytest as a supported test framework - Mailing list pgsql-hackers

From Jelte Fennema-Nio
Subject Re: RFC: adding pytest as a supported test framework
Date
Msg-id DDOUZE2TCU8O.89TN0AS4GLP7@jeltef.nl
Whole thread Raw
In response to Re: RFC: adding pytest as a supported test framework  (Jacob Champion <jacob.champion@enterprisedb.com>)
List pgsql-hackers
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.

Attachment

pgsql-hackers by date:

Previous
From: Nazir Bilal Yavuz
Date:
Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD
Next
From: Andres Freund
Date:
Subject: Re: Stack-based tracking of per-node WAL/buffer usage