From b6f1fab814d1d23399412ed5b26245de120afb65 Mon Sep 17 00:00:00 2001 From: Shai Berger Date: Tue, 25 Nov 2025 20:26:06 +0200 Subject: [PATCH] Test also against psycopg 3.x While at it, make the test matrix more sensible Fixes #9. --- .github/workflows/tests.yml | 25 ++++++++++++++++--------- pyproject.toml | 8 ++++++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fbbf879..ffdab87 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] - db_url: [ '', 'postgresql://pg:pgpass@localhost/bdmodels' ] + db-backend: ["sqlt", "pg2", "pg3"] steps: - name: Update Sqlite @@ -46,11 +46,18 @@ jobs: # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Tox me run: | - TOXPY="py$( echo ${{ matrix.python-version }} | sed s/\\.// )" - # Skip envs with the wrong Python using TOX_SKIP_ENV var. - # The below constructs, e.g. for py310, the string '(?!py310).*' - # (?!...) is negative lookahead; the expr matches anything which doed _not_ - # start with 'py310'; and all the matched envs are excluded, so this ensures - # we only run the envs defined for the given Python. - export TOX_SKIP_ENV='(?!'"${TOXPY}).*" - BDMODELS_DB=${{ matrix.db_url }} tox + TOXDB="${{ matrix.db-backend }}" + # Skip envs with the wrong db-backend using TOX_SKIP_ENV var. + # The below constructs, e.g. for sqlt the string '.*(? /dev/null); then + BDMODELS_DB='postgresql://pg:pgpass@localhost/bdmodels' + fi + export BDMODELS_DB + tox --skip-missing-interpreters true diff --git a/pyproject.toml b/pyproject.toml index 0639d71..e24be3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,9 +38,12 @@ sphinx-rtd-theme = "~3.0.2" dj-database-url = "^2.3.0" [tool.tox] +# Note: Per https://github.com/tox-dev/tox/discussions/3648 the legacy ini cannot be +# replaced by native pyproject.toml without duplicating definitions for factors +# (i.e. explicitly listing combinations of Python and Django etc) legacy_tox_ini = """ [tox] -envlist = py39-django42, py{310,311,312}-django{42,50,51,52}, py313-django{51,52,main} +envlist = py39-django42-{sqlt,pg2,pg3}, py{310,311,312}-django{42,50,51,52}-{sqlt,pg2,pg3}, py313-django{51,52,main}-{sqlt,pg2,pg3} isolated_build = True skipsdist = True @@ -53,7 +56,8 @@ deps = django51: Django>=5.1,<5.2 django52: Django>=5.2,<5.3 djangomain: git+https://github.com/django/django.git@main#egg=django - psycopg2-binary + pg2: psycopg2-binary + pg3: psycopg[binary] dj-database-url>=2.3.0,<3.0 changedir = test_bdmodels