From 5a34333a8fb39e8b4a99875b1b09013a8bfb54b2 Mon Sep 17 00:00:00 2001 From: Sergey Lavrinenko Date: Tue, 31 Mar 2026 20:36:42 +0300 Subject: [PATCH 1/3] Add dedicated CI jobs for DjangoMessage tests with Django 4.2/5.2/6.0 Closes #201 --- .github/workflows/tests.yaml | 27 ++++++++++++++++++- .../django_/test_django_integrations.py | 5 ++++ requirements/tests-django.txt | 2 ++ setup.cfg | 1 + tox.ini | 21 +++++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 requirements/tests-django.txt diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 217e777..a81737f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -34,7 +34,32 @@ jobs: python -m pip install -U pip - run: pip install tox - name: run tests - run: tox -e ${{ matrix.tox }} -- -m "not e2e" + run: tox -e ${{ matrix.tox }} -- -m "not e2e and not django" + + django: + name: "django / ${{ matrix.django }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - {django: '4.2', tox: django42} + - {django: '5.2', tox: django52} + - {django: '6.0', tox: django60} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: pip + - name: update pip + run: | + pip install -U wheel + pip install -U setuptools + python -m pip install -U pip + - run: pip install tox + - name: run django tests + run: tox -e ${{ matrix.tox }} typecheck: name: "typecheck" diff --git a/emails/testsuite/django_/test_django_integrations.py b/emails/testsuite/django_/test_django_integrations.py index 006a64e..199295b 100644 --- a/emails/testsuite/django_/test_django_integrations.py +++ b/emails/testsuite/django_/test_django_integrations.py @@ -1,8 +1,13 @@ import warnings +import pytest import emails import emails.message + +django = pytest.importorskip("django") from emails.django import DjangoMessage +pytestmark = pytest.mark.django + def test_django_message_proxy(django_email_backend): diff --git a/requirements/tests-django.txt b/requirements/tests-django.txt new file mode 100644 index 0000000..a4897ed --- /dev/null +++ b/requirements/tests-django.txt @@ -0,0 +1,2 @@ +--requirement=base.txt +--requirement=tests-base.txt diff --git a/setup.cfg b/setup.cfg index b3840e7..727ab7c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,6 +37,7 @@ ignore_errors = true norecursedirs = .* {arch} *.egg *.egg-info dist build requirements markers = e2e: tests that require a running SMTP server + django: tests that require Django [coverage:run] omit = emails/testsuite/* diff --git a/tox.ini b/tox.ini index 83d7093..3745480 100644 --- a/tox.ini +++ b/tox.ini @@ -30,6 +30,27 @@ deps = -rrequirements/tests.txt +[testenv:django42] +basepython = python3.12 +deps = + -rrequirements/tests-django.txt + Django>=4.2,<4.3 +commands = py.test -m django {posargs} + +[testenv:django52] +basepython = python3.12 +deps = + -rrequirements/tests-django.txt + Django>=5.2,<5.3 +commands = py.test -m django {posargs} + +[testenv:django60] +basepython = python3.12 +deps = + -rrequirements/tests-django.txt + Django>=6.0,<6.1 +commands = py.test -m django {posargs} + [testenv:typecheck] deps = mypy commands = mypy emails/ From 59dde190fa7e38d39bc5f92f2bcd92c2541eb6d9 Mon Sep 17 00:00:00 2001 From: Sergey Lavrinenko Date: Tue, 31 Mar 2026 20:40:40 +0300 Subject: [PATCH 2/3] Add coverage reporting to django tox envs --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 3745480..fb6373c 100644 --- a/tox.ini +++ b/tox.ini @@ -35,21 +35,21 @@ basepython = python3.12 deps = -rrequirements/tests-django.txt Django>=4.2,<4.3 -commands = py.test -m django {posargs} +commands = py.test --cov-report term --cov-report html --cov emails -m django {posargs} [testenv:django52] basepython = python3.12 deps = -rrequirements/tests-django.txt Django>=5.2,<5.3 -commands = py.test -m django {posargs} +commands = py.test --cov-report term --cov-report html --cov emails -m django {posargs} [testenv:django60] basepython = python3.12 deps = -rrequirements/tests-django.txt Django>=6.0,<6.1 -commands = py.test -m django {posargs} +commands = py.test --cov-report term --cov-report html --cov emails -m django {posargs} [testenv:typecheck] deps = mypy From 5296fc19f075254ce7fe17c2c536da5a3299b007 Mon Sep 17 00:00:00 2001 From: Sergey Lavrinenko Date: Tue, 31 Mar 2026 20:50:10 +0300 Subject: [PATCH 3/3] Fix coverage omit for testsuite by passing --cov-config=setup.cfg --- tox.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index fb6373c..4ae67e5 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = py310, py311, py312, py313, py314, pypy, style [testenv] passenv = TEST_*,SMTP_TEST_* -commands = py.test --cov-report term --cov-report html --cov emails {posargs} +commands = py.test --cov-report term --cov-report html --cov emails --cov-config=setup.cfg {posargs} [testenv:pypy] deps = @@ -35,21 +35,21 @@ basepython = python3.12 deps = -rrequirements/tests-django.txt Django>=4.2,<4.3 -commands = py.test --cov-report term --cov-report html --cov emails -m django {posargs} +commands = py.test --cov-report term --cov-report html --cov emails --cov-config=setup.cfg -m django {posargs} [testenv:django52] basepython = python3.12 deps = -rrequirements/tests-django.txt Django>=5.2,<5.3 -commands = py.test --cov-report term --cov-report html --cov emails -m django {posargs} +commands = py.test --cov-report term --cov-report html --cov emails --cov-config=setup.cfg -m django {posargs} [testenv:django60] basepython = python3.12 deps = -rrequirements/tests-django.txt Django>=6.0,<6.1 -commands = py.test --cov-report term --cov-report html --cov emails -m django {posargs} +commands = py.test --cov-report term --cov-report html --cov emails --cov-config=setup.cfg -m django {posargs} [testenv:typecheck] deps = mypy