duckdb / pg_duckdb

DuckDB-powered Postgres for high performance apps & analytics.
MIT License
1.23k stars 47 forks source link

Add pytest-based testing framework #143

Closed JelteF closed 2 weeks ago

JelteF commented 3 weeks ago

pgregress is easy to use an is part of Postgres, so it's often the first thing to use testing a Postgres extension. But it also quite limiting, since you can only execute SQL and a test fails as soon as any of the output is different.

This adds a Python based testing framework to the project, which allows to do more "application" style testing. It's based on the testing framework I wrote for PgBouncer, but I removed a bunch of stuff that only made sense when testing PgBouncer. Postgres has a similar framework included, but that uses Perl and I really don't want to write any Perl. Also pytest is a much nicer to use testing framework than what is available in Perl.

As an example of a test that cannot easily be written using pgregress I added a test for EXPLAIN ANALYZE. Support for EXPLAIN ANALYZE was added in #136, but writing a test was not possible because the Timing information would be flaky.

JelteF commented 2 weeks ago

Ruff is for auto formatting