From b792d7d4102e45d1f31548ef4b0a826ea0d2155e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 28 Oct 2024 10:53:47 -0400 Subject: [PATCH 01/32] update workflow action versions --- .github/workflows/tests.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e7f50b7..859e16e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,10 +50,12 @@ jobs: steps: - name: "Check out the repo" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" + with: + persist-credentials: false - name: "Set up Python" - uses: "actions/setup-python@v4" + uses: "actions/setup-python@v5" with: python-version: "${{ matrix.python-version }}" allow-prereleases: true @@ -85,10 +87,12 @@ jobs: steps: - name: "Check out the repo" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" + with: + persist-credentials: false - name: "Set up Python" - uses: "actions/setup-python@v2" + uses: "actions/setup-python@v5" with: python-version: "3.8" From e6bdc06d8993161a55341454bec19623bc836594 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 28 Oct 2024 10:59:33 -0400 Subject: [PATCH 02/32] test: adjust versions tox runs --- tox.ini | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 5c01601..a9217e2 100644 --- a/tox.ini +++ b/tox.ini @@ -14,21 +14,23 @@ [tox] envlist = - py38-django{22,32,42}-cov{6,7,tip}, + py38-django{22,32,42}-cov{6,761}, py39-django{22,32,42}-cov{6,7,tip}, - py310-django{32,42,tip}-cov{6,7,tip}, - py311-django{42,tip}-cov{6,7,tip}, - py312-django{tip}-cov{7,tip}, + py310-django{32,42,51,tip}-cov{6,7,tip}, + py311-django{42,51,tip}-cov{6,7,tip}, + py312-django{51,tip}-cov{7,tip}, check,pkgcheck,doc [testenv] deps = cov6: coverage>=6.0,<7.0 cov7: coverage>=7.0,<8.0 + cov761: coverage==7.6.1 covtip: git+https://github.com/nedbat/coveragepy.git django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 django42: Django>=4.2,<5.0 + django51: Django>=5.1,<6.0 djangotip: git+https://github.com/django/django.git pytest unittest-mixins==1.6 From 877b0420a0a0bcfb2a006cc8f409005bd03a10fb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 10 Nov 2024 15:53:41 -0500 Subject: [PATCH 03/32] build: declare django 5.1 compatibility --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 0132d17..f9d3400 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,7 @@ def read(*names, **kwargs): Framework :: Django :: 2.2 Framework :: Django :: 3.2 Framework :: Django :: 4.2 +Framework :: Django :: 5.1 """ setup( From f4a3aa066b6a14172e9e4239caa3f3f0358a3e45 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 27 Jan 2025 17:05:42 -0500 Subject: [PATCH 04/32] build: django 5.tip dropped 3.10 and 3.11, also test on 3.13 --- tox.ini | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index a9217e2..d76449b 100644 --- a/tox.ini +++ b/tox.ini @@ -16,9 +16,10 @@ envlist = py38-django{22,32,42}-cov{6,761}, py39-django{22,32,42}-cov{6,7,tip}, - py310-django{32,42,51,tip}-cov{6,7,tip}, - py311-django{42,51,tip}-cov{6,7,tip}, + py310-django{32,42,51}-cov{6,7,tip}, + py311-django{42,51}-cov{6,7,tip}, py312-django{51,tip}-cov{7,tip}, + py313-django{51,tip}-cov{7,tip}, check,pkgcheck,doc [testenv] @@ -80,3 +81,4 @@ python = 3.10: py310 3.11: py311 3.12: py312 + 3.13: py313 From 8bf14bcc59303c52898b23ad9b551d29124463ee Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 27 Jan 2025 18:59:11 -0500 Subject: [PATCH 05/32] add 3.13 classifier, and tweak setup.py --- setup.py | 7 ++++--- tox.ini | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index f9d3400..800fbb8 100644 --- a/setup.py +++ b/setup.py @@ -18,10 +18,11 @@ def read(*names, **kwargs): Parameter: encoding kwarg may be set """ - return open( + with open( join(dirname(__file__), *names), encoding=kwargs.get('encoding', 'utf8') - ).read() + ) as f: + return f.read() classifiers = """\ @@ -34,13 +35,13 @@ def read(*names, **kwargs): Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 +Programming Language :: Python :: 3.13 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Quality Assurance Topic :: Software Development :: Testing Development Status :: 5 - Production/Stable Framework :: Django -Framework :: Django :: 1.11 Framework :: Django :: 2.2 Framework :: Django :: 3.2 Framework :: Django :: 4.2 diff --git a/tox.ini b/tox.ini index d76449b..f95612c 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ # [tox] +# When changing this, also update the classifiers in setup.py: envlist = py38-django{22,32,42}-cov{6,761}, py39-django{22,32,42}-cov{6,7,tip}, From a1f1d93bccbd495e0d019052a6e411f88f5cbc6f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 27 Jan 2025 19:18:51 -0500 Subject: [PATCH 06/32] drop Python 3.8 --- setup.py | 1 - tox.ini | 3 --- 2 files changed, 4 deletions(-) diff --git a/setup.py b/setup.py index 800fbb8..26e19d3 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,6 @@ def read(*names, **kwargs): Intended Audience :: Developers License :: OSI Approved :: Apache Software License Operating System :: OS Independent -Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 diff --git a/tox.ini b/tox.ini index f95612c..31e67dd 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,6 @@ [tox] # When changing this, also update the classifiers in setup.py: envlist = - py38-django{22,32,42}-cov{6,761}, py39-django{22,32,42}-cov{6,7,tip}, py310-django{32,42,51}-cov{6,7,tip}, py311-django{42,51}-cov{6,7,tip}, @@ -27,7 +26,6 @@ envlist = deps = cov6: coverage>=6.0,<7.0 cov7: coverage>=7.0,<8.0 - cov761: coverage==7.6.1 covtip: git+https://github.com/nedbat/coveragepy.git django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 @@ -77,7 +75,6 @@ commands = [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 From 401654a016a9c8e253b4b72bdd021544b4c714e2 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 27 Jan 2025 21:20:47 -0500 Subject: [PATCH 07/32] a few more version fixups --- .github/workflows/tests.yml | 4 ++-- README.rst | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 859e16e..26e2d69 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,11 +41,11 @@ jobs: python-version: # When changing this list, be sure to check the [gh-actions] list in # tox.ini so that tox will run properly. - - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" + - "3.13" fail-fast: false steps: @@ -94,7 +94,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v5" with: - python-version: "3.8" + python-version: "3.9" - name: "Install dependencies" run: | diff --git a/README.rst b/README.rst index 7ce3fd4..7a73396 100644 --- a/README.rst +++ b/README.rst @@ -31,13 +31,13 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. Supported on: -- Python: 3.8 through 3.12. +- Python: 3.9 through 3.13. -- Django: 2.x, 3.x and 4.x. +- Django: 2.x, 3.x, 4.x and 5.x. - Coverage.py: 6.x or higher. -The plugin is pip installable:: +The plugin is pip-installable:: $ python3 -m pip install django_coverage_plugin From 464ff86b0a41abef0629d9a463378fcae08031d2 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 27 Jan 2025 21:27:38 -0500 Subject: [PATCH 08/32] build: not sure when rst2html.py became rst2html --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 31e67dd..e8f5b22 100644 --- a/tox.ini +++ b/tox.ini @@ -71,7 +71,7 @@ deps = sphinx commands = - rst2html.py --strict README.rst /tmp/django_coverage_plugin_README.html + rst2html --strict README.rst /tmp/django_coverage_plugin_README.html [gh-actions] python = From 89373eb8b7ffee0110cba1b7314c46789da578d5 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 15 Jun 2025 12:31:39 +0100 Subject: [PATCH 09/32] declare official support for Django 5.2 (#103) * test: fix Django 5.1 tox env to not install 5.2 * test: add Django 5.2 to tox runs * build: declare django 5.2 compatibility --- setup.py | 1 + tox.ini | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 26e19d3..ad31d9b 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ def read(*names, **kwargs): Framework :: Django :: 3.2 Framework :: Django :: 4.2 Framework :: Django :: 5.1 +Framework :: Django :: 5.2 """ setup( diff --git a/tox.ini b/tox.ini index e8f5b22..25d6da1 100644 --- a/tox.ini +++ b/tox.ini @@ -16,10 +16,10 @@ # When changing this, also update the classifiers in setup.py: envlist = py39-django{22,32,42}-cov{6,7,tip}, - py310-django{32,42,51}-cov{6,7,tip}, - py311-django{42,51}-cov{6,7,tip}, - py312-django{51,tip}-cov{7,tip}, - py313-django{51,tip}-cov{7,tip}, + py310-django{32,42,51,52}-cov{6,7,tip}, + py311-django{42,51,52}-cov{6,7,tip}, + py312-django{51,52,tip}-cov{7,tip}, + py313-django{51,52,tip}-cov{7,tip}, check,pkgcheck,doc [testenv] @@ -30,7 +30,8 @@ deps = django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 django42: Django>=4.2,<5.0 - django51: Django>=5.1,<6.0 + django51: Django>=5.1,<5.2 + django52: Django>=5.2,<6.0 djangotip: git+https://github.com/django/django.git pytest unittest-mixins==1.6 From b1c63409590c2688e9ef190896c8bec26f88ac8c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 08:03:10 -0400 Subject: [PATCH 10/32] no need to mention django 5.1 specifically --- README.rst | 8 ++++---- setup.py | 1 - tox.ini | 9 ++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 7a73396..10a6c9a 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,8 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. .. |versions| image:: https://img.shields.io/pypi/pyversions/django_coverage_plugin.svg :target: https://pypi.python.org/pypi/django_coverage_plugin :alt: Supported Python Versions -.. |djversions| image:: https://img.shields.io/badge/Django-1.8%20%7C%201.11%20%7C%202.2%20%7C%203.2%20%7C%204.1-44b78b.svg +.. the Django badge says: `2.2 | 3.2 | 4.2 | 5.2` +.. |djversions| image:: https://img.shields.io/badge/Django-2.2%20%7C%203.2%20%7C%204.2%20%7C%205.2-44b78b.svg :target: https://pypi.python.org/pypi/django_coverage_plugin :alt: Supported Django Versions @@ -33,7 +34,7 @@ Supported on: - Python: 3.9 through 3.13. -- Django: 2.x, 3.x, 4.x and 5.x. +- Django: 2.2 through 5.2. - Coverage.py: 6.x or higher. @@ -49,8 +50,7 @@ To run it, add this setting to your ``.coveragerc`` file:: Then run your tests under `coverage.py`_. You will see your templates listed in your coverage report along with -your Python modules. Please use `coverage.py`_ v4.4 or greater to allow -the plugin to identify untested templates. +your Python modules. If you get a :code:`django.core.exceptions.ImproperlyConfigured` error, you need to set the :code:`DJANGO_SETTINGS_MODULE` environment variable. diff --git a/setup.py b/setup.py index ad31d9b..aada28d 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,6 @@ def read(*names, **kwargs): Framework :: Django :: 2.2 Framework :: Django :: 3.2 Framework :: Django :: 4.2 -Framework :: Django :: 5.1 Framework :: Django :: 5.2 """ diff --git a/tox.ini b/tox.ini index 25d6da1..ac3f910 100644 --- a/tox.ini +++ b/tox.ini @@ -16,10 +16,10 @@ # When changing this, also update the classifiers in setup.py: envlist = py39-django{22,32,42}-cov{6,7,tip}, - py310-django{32,42,51,52}-cov{6,7,tip}, - py311-django{42,51,52}-cov{6,7,tip}, - py312-django{51,52,tip}-cov{7,tip}, - py313-django{51,52,tip}-cov{7,tip}, + py310-django{32,42,52}-cov{6,7,tip}, + py311-django{42,52}-cov{6,7,tip}, + py312-django{52,tip}-cov{7,tip}, + py313-django{52,tip}-cov{7,tip}, check,pkgcheck,doc [testenv] @@ -30,7 +30,6 @@ deps = django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 django42: Django>=4.2,<5.0 - django51: Django>=5.1,<5.2 django52: Django>=5.2,<6.0 djangotip: git+https://github.com/django/django.git pytest From 9882b4e235a74fa275f33b880d2d09142f3f4ed7 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 08:13:22 -0400 Subject: [PATCH 11/32] modern license specification --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index aada28d..97135ee 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,6 @@ def read(*names, **kwargs): classifiers = """\ Environment :: Console Intended Audience :: Developers -License :: OSI Approved :: Apache Software License Operating System :: OS Independent Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 From 0d271c36263a3dfe64347bd327d6466d40c5f565 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 08:13:46 -0400 Subject: [PATCH 12/32] build: distributions should include more files --- MANIFEST.in | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 74dd042..a38013a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,14 +2,11 @@ # - http://www.apache.org/licenses/LICENSE-2.0 # - https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt -exclude .isort.cfg -exclude howto.txt -exclude Makefile -exclude requirements.txt -exclude tox.ini -exclude .editorconfig -include AUTHORS.txt -include LICENSE.txt -include NOTICE.txt -include README.rst -prune tests +include *.txt +include .editorconfig +include .isort.cfg +include Makefile +include tox.ini + +recursive-include .github * +recursive-include tests *.py From cc7784f576bc63a2a80a5f53d594322c22537cca Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 08:39:25 -0400 Subject: [PATCH 13/32] docs: keep the change history current --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 10a6c9a..f0d7f44 100644 --- a/README.rst +++ b/README.rst @@ -137,6 +137,12 @@ History .. scriv-insert-here +v3.1.1 — 2025-06-15 +------------------- + +Support changes: dropped Python 3.8, added Python 3.13. Added Django 5.2. + + v3.1.0 — 2023-07-10 ------------------- From 9f7a8561489b2ea3955cd3da5fe3cbd65657d922 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 08:42:55 -0400 Subject: [PATCH 14/32] build: add testpypi --- Makefile | 3 +++ NOTICE.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 85fc6c6..9eb9755 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ kit: ## Make the source distribution. kit_upload: ## Upload the built distributions to PyPI. python -m twine upload --verbose dist/* +test_upload: ## Upload the distrubutions to test PyPI. + python -m twine upload --verbose --repository testpypi dist/* + tag: ## Make a git tag with the version number. git tag -s -m "Version v$$(python setup.py --version)" v$$(python setup.py --version) git push --all diff --git a/NOTICE.txt b/NOTICE.txt index 69e5a4f..7803be8 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,4 +1,4 @@ -Copyright 2015-2022 Ned Batchelder. All rights reserved. +Copyright 2015-2025 Ned Batchelder. All rights reserved. Except where noted otherwise, this software is licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in From 8686b22cacd48e26f130ead4711d34f785db5103 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 08:46:56 -0400 Subject: [PATCH 15/32] try uploading with badges --- setup.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 97135ee..64bb08c 100644 --- a/setup.py +++ b/setup.py @@ -48,15 +48,9 @@ def read(*names, **kwargs): setup( name='django_coverage_plugin', - version='3.1.0', + version='3.1.1rc1', description='Django template coverage.py plugin', - long_description=( - re.sub( - '(?ms)^.. start-badges.*^.. end-badges', - '', - read('README.rst'), - ) - ), + long_description=(read('README.rst')), long_description_content_type='text/x-rst', author='Ned Batchelder', author_email='ned@nedbatchelder.com', From 2cd85c6525b243fd459d36f4ee0ab17d65dd3035 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 09:51:39 -0400 Subject: [PATCH 16/32] build: more-usual make targets --- Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9eb9755..1e0dc10 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ # Makefile for django_coverage_plugin +.PHONY: help test clean sterile dist pypi test_pypi tag ghrelease + help: ## Show this help. @echo "Available targets:" @grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf " %-26s%s\n", $$1, $$2}' @@ -24,18 +26,18 @@ clean: ## Remove non-source files. sterile: clean ## Remove all non-controlled content, even if expensive. -rm -rf .tox* -kit: ## Make the source distribution. +dist: ## Make the source distribution. python -m build python -m twine check dist/* -kit_upload: ## Upload the built distributions to PyPI. +pypi: ## Upload the built distributions to PyPI. python -m twine upload --verbose dist/* -test_upload: ## Upload the distrubutions to test PyPI. - python -m twine upload --verbose --repository testpypi dist/* +test_pypi: ## Upload the distributions to test PyPI. + python -m twine upload --verbose --repository testpypi --password $$TWINE_TEST_PASSWORD dist/* tag: ## Make a git tag with the version number. - git tag -s -m "Version v$$(python setup.py --version)" v$$(python setup.py --version) + git tag -s -m "Version v$$(python -c 'import django_coverage_plugin; print(django_coverage_plugin.__version__)')" v$$(python -c 'import django_coverage_plugin; print(django_coverage_plugin.__version__)') git push --all ghrelease: ## Make a GitHub release for the latest version. From 30856dfe975e4bd47c9532c44ebe7009e0687be1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 09:52:32 -0400 Subject: [PATCH 17/32] build: move packaging and config to pyproject.toml Thanks, Claude. --- django_coverage_plugin/__init__.py | 2 + pyproject.toml | 65 ++++++++++++++++++++++++++++++ setup.cfg | 14 +------ setup.py | 59 +++------------------------ 4 files changed, 75 insertions(+), 65 deletions(-) create mode 100644 pyproject.toml diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index bac9149..342d45d 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -3,6 +3,8 @@ """Django Template Coverage Plugin""" +__version__ = "3.1.1rc1" + from .plugin import DjangoTemplatePluginException # noqa from .plugin import DjangoTemplatePlugin diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e4fcf77 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ +# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt + +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "django_coverage_plugin" +description = "Django template coverage.py plugin" +readme = "README.rst" +authors = [ + {name = "Ned Batchelder", email = "ned@nedbatchelder.com"}, +] +license = "Apache-2.0" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Framework :: Django", + "Framework :: Django :: 2.2", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.2", + "Framework :: Django :: 5.2", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", +] +requires-python = ">= 3.9" +dependencies = [ + "coverage", +] +dynamic = ["version"] + +[project.urls] +"Homepage" = "https://github.com/nedbat/django_coverage_plugin" +"Bug Tracker" = "https://github.com/nedbat/django_coverage_plugin/issues" +"Source" = "https://github.com/nedbat/django_coverage_plugin" + +[tool.setuptools.dynamic] +version = {attr = "django_coverage_plugin.__version__"} + +[tool.setuptools.packages.find] +include = ["django_coverage_plugin*"] + +[tool.pytest.ini_options] +# How come these warnings are suppressed successfully here, but not in conftest.py?? +filterwarnings = [ + # ignore all DeprecationWarnings... + "ignore::DeprecationWarning", + # ...but show them if they are from our code. + "default::DeprecationWarning:django_coverage_plugin", +] + +[tool.scriv] +fragment_directory = "scriv.d" +output_file = "README.rst" +rst_header_chars = "-." \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 91522f4..51e49e5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,15 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt -[tool:pytest] -# How come these warnings are suppressed successfully here, but not in conftest.py?? -filterwarnings = - # ignore all DeprecationWarnings... - ignore::DeprecationWarning - # ...but show them if they are from our code. - default::DeprecationWarning:django_coverage_plugin - -[scriv] -fragment_directory = scriv.d -output_file = README.rst -rst_header_chars = -. +# Configuration has moved to pyproject.toml +# This file can be removed once migration is complete diff --git a/setup.py b/setup.py index 64bb08c..5591278 100644 --- a/setup.py +++ b/setup.py @@ -5,60 +5,13 @@ - http://www.apache.org/licenses/LICENSE-2.0 - https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +DEPRECATED: This file is kept for backward compatibility. +All configuration has moved to pyproject.toml. +This file can be removed once migration is complete. """ -import re -from os.path import dirname, join - +# For backward compatibility, import from setuptools from setuptools import setup - -def read(*names, **kwargs): - """Read and return contents of file - - Parameter: encoding kwarg may be set - """ - with open( - join(dirname(__file__), *names), - encoding=kwargs.get('encoding', 'utf8') - ) as f: - return f.read() - - -classifiers = """\ -Environment :: Console -Intended Audience :: Developers -Operating System :: OS Independent -Programming Language :: Python :: 3.9 -Programming Language :: Python :: 3.10 -Programming Language :: Python :: 3.11 -Programming Language :: Python :: 3.12 -Programming Language :: Python :: 3.13 -Programming Language :: Python :: Implementation :: CPython -Programming Language :: Python :: Implementation :: PyPy -Topic :: Software Development :: Quality Assurance -Topic :: Software Development :: Testing -Development Status :: 5 - Production/Stable -Framework :: Django -Framework :: Django :: 2.2 -Framework :: Django :: 3.2 -Framework :: Django :: 4.2 -Framework :: Django :: 5.2 -""" - -setup( - name='django_coverage_plugin', - version='3.1.1rc1', - description='Django template coverage.py plugin', - long_description=(read('README.rst')), - long_description_content_type='text/x-rst', - author='Ned Batchelder', - author_email='ned@nedbatchelder.com', - url='https://github.com/nedbat/django_coverage_plugin', - packages=['django_coverage_plugin'], - install_requires=[ - 'coverage', - ], - license='Apache-2.0', - classifiers=classifiers.splitlines(), -) +# All configuration is now in pyproject.toml +setup() From 11c54bceead4ceddbe0fa9d68943307689d2ac7e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 09:56:29 -0400 Subject: [PATCH 18/32] build: remove setup.py and setup.cfg --- django_coverage_plugin/__init__.py | 2 +- howto.txt | 9 +++++---- setup.cfg | 5 ----- setup.py | 17 ----------------- tox.ini | 4 ++-- 5 files changed, 8 insertions(+), 29 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index 342d45d..94463a3 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -3,7 +3,7 @@ """Django Template Coverage Plugin""" -__version__ = "3.1.1rc1" +__version__ = "3.1.1rc2" from .plugin import DjangoTemplatePluginException # noqa from .plugin import DjangoTemplatePlugin diff --git a/howto.txt b/howto.txt index f3cdaa8..f0f4bd7 100644 --- a/howto.txt +++ b/howto.txt @@ -1,7 +1,7 @@ * Release checklist -- Version number in setup.py -- Classifiers in setup.py +- Version number in __init__.py +- Classifiers in pyproject.toml https://pypi.python.org/pypi?%3Aaction=list_classifiers eg: Development Status :: 3 - Alpha @@ -9,7 +9,8 @@ - Copyright date in NOTICE.txt - Update README.rst with latest changes - Kits: - $ make clean kit - $ make kit_upload + $ make clean dist + $ make test_pypi + $ make pypi $ make tag $ make ghrelease diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 51e49e5..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt - -# Configuration has moved to pyproject.toml -# This file can be removed once migration is complete diff --git a/setup.py b/setup.py deleted file mode 100644 index 5591278..0000000 --- a/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -"""Setup for Django Coverage Plugin - -Licensed under the Apache 2.0 License -- http://www.apache.org/licenses/LICENSE-2.0 -- https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt - -DEPRECATED: This file is kept for backward compatibility. -All configuration has moved to pyproject.toml. -This file can be removed once migration is complete. -""" - -# For backward compatibility, import from setuptools -from setuptools import setup - -# All configuration is now in pyproject.toml -setup() diff --git a/tox.ini b/tox.ini index ac3f910..caa351b 100644 --- a/tox.ini +++ b/tox.ini @@ -49,8 +49,8 @@ deps = isort commands = - flake8 --max-line-length=100 setup.py django_coverage_plugin tests setup.py - isort --check-only --diff django_coverage_plugin tests setup.py + flake8 --max-line-length=100 django_coverage_plugin tests + isort --check-only --diff django_coverage_plugin tests [testenv:pkgcheck] skip_install = true From 2d727d9c1f0370856c9058261e1fc0cec246d646 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 10:26:28 -0400 Subject: [PATCH 19/32] build: fix a packaging tweak; more badges --- README.rst | 14 ++++++++++---- django_coverage_plugin/__init__.py | 2 +- pyproject.toml | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index f0d7f44..f16497d 100644 --- a/README.rst +++ b/README.rst @@ -4,10 +4,9 @@ Django Template Coverage.py Plugin A `coverage.py`_ plugin to measure test coverage of Django templates. -.. start-badges - | |status| |kit| |license| | |versions| |djversions| +| |sponsor| |bluesky-nedbat| |mastodon-nedbat| .. |status| image:: https://img.shields.io/pypi/status/django_coverage_plugin.svg :target: https://pypi.python.org/pypi/django_coverage_plugin @@ -25,10 +24,17 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. .. |djversions| image:: https://img.shields.io/badge/Django-2.2%20%7C%203.2%20%7C%204.2%20%7C%205.2-44b78b.svg :target: https://pypi.python.org/pypi/django_coverage_plugin :alt: Supported Django Versions +.. |sponsor| image:: https://img.shields.io/badge/%E2%9D%A4-Sponsor%20me-brightgreen?style=flat&logo=GitHub + :target: https://github.com/sponsors/nedbat + :alt: Sponsor me on GitHub +.. |bluesky-nedbat| image:: https://img.shields.io/badge/dynamic/json?style=flat&color=96a3b0&labelColor=3686f7&logo=icloud&logoColor=white&label=@nedbat&url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%3Factor=nedbat.com&query=followersCount + :target: https://bsky.app/profile/nedbat.com + :alt: nedbat on Bluesky +.. |mastodon-nedbat| image:: https://img.shields.io/badge/dynamic/json?style=flat&labelColor=450657&logo=mastodon&logoColor=ffffff&label=@nedbat&query=followers_count&url=https%3A%2F%2Fhachyderm.io%2Fapi%2Fv1%2Faccounts%2Flookup%3Facct=nedbat + :target: https://hachyderm.io/@nedbat + :alt: nedbat on Mastodon ------------------- -.. end-badges Supported on: diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index 94463a3..c14666d 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -3,7 +3,7 @@ """Django Template Coverage Plugin""" -__version__ = "3.1.1rc2" +__version__ = "3.1.1rc3" from .plugin import DjangoTemplatePluginException # noqa from .plugin import DjangoTemplatePlugin diff --git a/pyproject.toml b/pyproject.toml index e4fcf77..dd90c5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ # For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt [build-system] -requires = ["setuptools>=61.0", "wheel"] +requires = ["setuptools>=77.0", "wheel"] build-backend = "setuptools.build_meta" [project] @@ -18,7 +18,7 @@ classifiers = [ "Environment :: Console", "Framework :: Django", "Framework :: Django :: 2.2", - "Framework :: Django :: 3.2", + "Framework :: Django :: 3.2", "Framework :: Django :: 4.2", "Framework :: Django :: 5.2", "Intended Audience :: Developers", @@ -62,4 +62,4 @@ filterwarnings = [ [tool.scriv] fragment_directory = "scriv.d" output_file = "README.rst" -rst_header_chars = "-." \ No newline at end of file +rst_header_chars = "-." From eb65668bc82f8bfad270ad68ee91af6432743333 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 10:32:18 -0400 Subject: [PATCH 20/32] build: v3.1.1 --- django_coverage_plugin/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index c14666d..5fbdef1 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -3,7 +3,7 @@ """Django Template Coverage Plugin""" -__version__ = "3.1.1rc3" +__version__ = "3.1.1" from .plugin import DjangoTemplatePluginException # noqa from .plugin import DjangoTemplatePlugin From 740bbbee7d73c969d24c6e9d5aac68e9735782e5 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 11:01:36 -0400 Subject: [PATCH 21/32] build: fix the tagging --- Makefile | 4 +++- requirements.txt | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1e0dc10..6b6ff91 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,10 @@ pypi: ## Upload the built distributions to PyPI. test_pypi: ## Upload the distributions to test PyPI. python -m twine upload --verbose --repository testpypi --password $$TWINE_TEST_PASSWORD dist/* +VERSION := $(shell python -c "import django_coverage_plugin as me; print(me.__version__)") + tag: ## Make a git tag with the version number. - git tag -s -m "Version v$$(python -c 'import django_coverage_plugin; print(django_coverage_plugin.__version__)')" v$$(python -c 'import django_coverage_plugin; print(django_coverage_plugin.__version__)') + git tag -s -m "Version v$(VERSION)" v$(VERSION) git push --all ghrelease: ## Make a GitHub release for the latest version. diff --git a/requirements.txt b/requirements.txt index fbf51ac..7463b6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,7 @@ tox >= 1.8 build scriv twine + +# We need django and coverage to be able to import ourselves to make a tag... +django +coverage From c612c66a6d0a82a158c3ce6f0a172ef8a3cabecf Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Jun 2025 17:14:37 -0400 Subject: [PATCH 22/32] fix: django should be a requirement of ours, and make tagging smoother --- Makefile | 10 ++++++---- pyproject.toml | 1 + requirements.txt | 10 ++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 6b6ff91..18df828 100644 --- a/Makefile +++ b/Makefile @@ -36,11 +36,13 @@ pypi: ## Upload the built distributions to PyPI. test_pypi: ## Upload the distributions to test PyPI. python -m twine upload --verbose --repository testpypi --password $$TWINE_TEST_PASSWORD dist/* -VERSION := $(shell python -c "import django_coverage_plugin as me; print(me.__version__)") +_install_e: + python -m pip install -q -e . -tag: ## Make a git tag with the version number. - git tag -s -m "Version v$(VERSION)" v$(VERSION) - git push --all +tag: _install_e ## Make a git tag with the version number. + @export VER="$$(python -c "import django_coverage_plugin as me; print(me.__version__)")" && \ + echo git tag -s -m "Version v$$VER" v$$VER + echo git push --all ghrelease: ## Make a GitHub release for the latest version. python -m scriv github-release diff --git a/pyproject.toml b/pyproject.toml index dd90c5f..c71bdc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ classifiers = [ requires-python = ">= 3.9" dependencies = [ "coverage", + "Django", ] dynamic = ["version"] diff --git a/requirements.txt b/requirements.txt index 7463b6f..fe664e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,7 @@ -# To run tests, we just need tox. -tox >= 1.8 +# To run tests, we just need tox: +tox + +# For releases: build scriv twine - -# We need django and coverage to be able to import ourselves to make a tag... -django -coverage From a24002821f4010fbed130188311b2089200945ee Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 5 Oct 2025 16:05:10 -0400 Subject: [PATCH 23/32] drop Python 3.9, Django 2.2. Add Python 3.14 --- .github/workflows/tests.yml | 4 +-- README.rst | 14 ++++++--- django_coverage_plugin/__init__.py | 2 +- django_coverage_plugin/plugin.py | 47 +++++------------------------- pyproject.toml | 5 ++-- tox.ini | 10 +++++-- 6 files changed, 29 insertions(+), 53 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 26e2d69..4deb5b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,11 +41,11 @@ jobs: python-version: # When changing this list, be sure to check the [gh-actions] list in # tox.ini so that tox will run properly. - - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" + - "3.14" fail-fast: false steps: @@ -94,7 +94,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v5" with: - python-version: "3.9" + python-version: "3.10" - name: "Install dependencies" run: | diff --git a/README.rst b/README.rst index f16497d..b735872 100644 --- a/README.rst +++ b/README.rst @@ -20,8 +20,8 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. .. |versions| image:: https://img.shields.io/pypi/pyversions/django_coverage_plugin.svg :target: https://pypi.python.org/pypi/django_coverage_plugin :alt: Supported Python Versions -.. the Django badge says: `2.2 | 3.2 | 4.2 | 5.2` -.. |djversions| image:: https://img.shields.io/badge/Django-2.2%20%7C%203.2%20%7C%204.2%20%7C%205.2-44b78b.svg +.. the Django badge says: `3.2 | 4.2 | 5.2` +.. |djversions| image:: https://img.shields.io/badge/Django-3.2%20%7C%204.2%20%7C%205.2-44b78b.svg :target: https://pypi.python.org/pypi/django_coverage_plugin :alt: Supported Django Versions .. |sponsor| image:: https://img.shields.io/badge/%E2%9D%A4-Sponsor%20me-brightgreen?style=flat&logo=GitHub @@ -38,9 +38,9 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. Supported on: -- Python: 3.9 through 3.13. +- Python: 3.10 through 3.14. -- Django: 2.2 through 5.2. +- Django: 3.2 through 5.2. - Coverage.py: 6.x or higher. @@ -143,6 +143,12 @@ History .. scriv-insert-here +v3.2.0 — 2025-10-05 +------------------- + +Drop Python 3.9 and Django 2.2. Add Python 3.14. + + v3.1.1 — 2025-06-15 ------------------- diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index 5fbdef1..a427ff8 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -3,7 +3,7 @@ """Django Template Coverage Plugin""" -__version__ = "3.1.1" +__version__ = "3.2.0" from .plugin import DjangoTemplatePluginException # noqa from .plugin import DjangoTemplatePlugin diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 158ee9a..b97a5a7 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -6,41 +6,14 @@ import os.path import re -try: - from coverage.exceptions import NoSource -except ImportError: - # for coverage 5.x - from coverage.misc import NoSource import coverage.plugin import django import django.template -from django.template.base import Lexer, NodeList, Template, TextNode +from coverage.exceptions import NoSource +from django.template.base import Lexer, NodeList, Template, TextNode, TokenType from django.template.defaulttags import VerbatimNode from django.templatetags.i18n import BlockTranslateNode -try: - from django.template.base import TokenType - - def _token_name(token_type): - token_type.name.capitalize() - -except ImportError: - # Django <2.1 uses separate constants for token types - from django.template.base import ( - TOKEN_BLOCK, - TOKEN_MAPPING, - TOKEN_TEXT, - TOKEN_VAR, - ) - - class TokenType: - TEXT = TOKEN_TEXT - VAR = TOKEN_VAR - BLOCK = TOKEN_BLOCK - - def _token_name(token_type): - return TOKEN_MAPPING[token_type] - class DjangoTemplatePluginException(Exception): """Used for any errors from the plugin itself.""" @@ -96,8 +69,8 @@ def check_debug(): return True -if django.VERSION < (2, 0): - raise RuntimeError("Django Coverage Plugin requires Django 2.x or higher") +if django.VERSION < (3, 0): + raise RuntimeError("Django Coverage Plugin requires Django 3.x or higher") # Since we are grabbing at internal details, we have to adapt as they @@ -129,14 +102,8 @@ def read_template_source(filename): if not settings.configured: settings.configure() - with open(filename, "rb") as f: - # The FILE_CHARSET setting will be removed in 3.1: - # https://docs.djangoproject.com/en/3.0/ref/settings/#file-charset - if django.VERSION >= (3, 1): - charset = 'utf-8' - else: - charset = settings.FILE_CHARSET - text = f.read().decode(charset) + with open(filename, "r", encoding="utf-8") as f: + text = f.read() return text @@ -326,7 +293,7 @@ def lines(self): if SHOW_PARSING: print( "%10s %2d: %r" % ( - _token_name(token.token_type), + token.token_type.capitalize(), token.lineno, token.contents, ) diff --git a/pyproject.toml b/pyproject.toml index c71bdc9..9b4d29b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,23 +17,22 @@ classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Framework :: Django", - "Framework :: Django :: 2.2", "Framework :: Django :: 3.2", "Framework :: Django :: 4.2", "Framework :: Django :: 5.2", "Intended Audience :: Developers", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Quality Assurance", "Topic :: Software Development :: Testing", ] -requires-python = ">= 3.9" +requires-python = ">= 3.10" dependencies = [ "coverage", "Django", diff --git a/tox.ini b/tox.ini index caa351b..08e6683 100644 --- a/tox.ini +++ b/tox.ini @@ -15,11 +15,11 @@ [tox] # When changing this, also update the classifiers in setup.py: envlist = - py39-django{22,32,42}-cov{6,7,tip}, py310-django{32,42,52}-cov{6,7,tip}, py311-django{42,52}-cov{6,7,tip}, py312-django{52,tip}-cov{7,tip}, py313-django{52,tip}-cov{7,tip}, + py314-django{52,tip}-cov{7,tip}, check,pkgcheck,doc [testenv] @@ -27,7 +27,6 @@ deps = cov6: coverage>=6.0,<7.0 cov7: coverage>=7.0,<8.0 covtip: git+https://github.com/nedbat/coveragepy.git - django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 django42: Django>=4.2,<5.0 django52: Django>=5.2,<6.0 @@ -43,6 +42,11 @@ usedevelop = True passenv = * +setenv = + # In later versions of Python, the default coverage.py core is sysmon, + # which doesn't support plugins like us. Force ctrace instead. + py3{12,13,14}: COVERAGE_CORE=ctrace + [testenv:check] deps = flake8 @@ -75,8 +79,8 @@ commands = [gh-actions] python = - 3.9: py39 3.10: py310 3.11: py311 3.12: py312 3.13: py313 + 3.14: py314 From 1c5100c1b818b02c0e6f2465beff932c30981a0f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 5 Oct 2025 18:44:14 -0400 Subject: [PATCH 24/32] fix 'make tag' --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 18df828..65eee1e 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,8 @@ _install_e: tag: _install_e ## Make a git tag with the version number. @export VER="$$(python -c "import django_coverage_plugin as me; print(me.__version__)")" && \ - echo git tag -s -m "Version v$$VER" v$$VER - echo git push --all + git tag -s -m "Version v$$VER" v$$VER + git push --all ghrelease: ## Make a GitHub release for the latest version. python -m scriv github-release From 544a761f298baeecf94ce37813ed088a1a09c6cf Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 9 Nov 2025 11:41:09 -0500 Subject: [PATCH 25/32] docs: update license notice to new location --- .editorconfig | 2 +- MANIFEST.in | 2 +- Makefile | 2 +- django_coverage_plugin/__init__.py | 2 +- django_coverage_plugin/plugin.py | 2 +- pyproject.toml | 2 +- tests/__init__.py | 2 +- tests/banner.py | 2 +- tests/conftest.py | 2 +- tests/plugin_test.py | 2 +- tests/test_engines.py | 2 +- tests/test_extends.py | 2 +- tests/test_flow.py | 2 +- tests/test_helpers.py | 2 +- tests/test_html.py | 2 +- tests/test_i18n.py | 2 +- tests/test_settings.py | 2 +- tests/test_simple.py | 2 +- tests/test_source.py | 2 +- tox.ini | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.editorconfig b/.editorconfig index 88200b6..6e7851e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt # This file is for unifying the coding style for different editors and IDEs. # More information at http://EditorConfig.org diff --git a/MANIFEST.in b/MANIFEST.in index a38013a..b220a56 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ # Licensed under the Apache 2.0 License # - http://www.apache.org/licenses/LICENSE-2.0 -# - https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# - https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt include *.txt include .editorconfig diff --git a/Makefile b/Makefile index 65eee1e..8d302f0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt # Makefile for django_coverage_plugin diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index a427ff8..f346811 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Django Template Coverage Plugin""" diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index b97a5a7..13e9c41 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """The Django template coverage plugin.""" diff --git a/pyproject.toml b/pyproject.toml index 9b4d29b..6bc35c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt [build-system] requires = ["setuptools>=77.0", "wheel"] diff --git a/tests/__init__.py b/tests/__init__.py index 2d2b590..d4318d5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """The tests for the Django Coverage Plugin.""" diff --git a/tests/banner.py b/tests/banner.py index ff6e7aa..8200b15 100644 --- a/tests/banner.py +++ b/tests/banner.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """For printing the versions from tox.ini.""" diff --git a/tests/conftest.py b/tests/conftest.py index 0852e87..5c8f6d7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """ Pytest auto configuration. diff --git a/tests/plugin_test.py b/tests/plugin_test.py index cc90be8..f103454 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Base classes and helpers for testing the plugin.""" diff --git a/tests/test_engines.py b/tests/test_engines.py index fdaa2ca..3bdbe32 100644 --- a/tests/test_engines.py +++ b/tests/test_engines.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Tests of multiple engines for django_coverage_plugin.""" diff --git a/tests/test_extends.py b/tests/test_extends.py index 4b3df69..3f7a987 100644 --- a/tests/test_extends.py +++ b/tests/test_extends.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Tests of template inheritance for django_coverage_plugin.""" diff --git a/tests/test_flow.py b/tests/test_flow.py index 2a00709..db83fa8 100644 --- a/tests/test_flow.py +++ b/tests/test_flow.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Tests of control-flow structures for django_coverage_plugin.""" diff --git a/tests/test_helpers.py b/tests/test_helpers.py index d0e919c..467d879 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Test helpers for the django coverage plugin.""" diff --git a/tests/test_html.py b/tests/test_html.py index 5038468..b71537b 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Tests of HTML reporting for django_coverage_plugin.""" diff --git a/tests/test_i18n.py b/tests/test_i18n.py index e68b920..40affec 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Tests of i18n tags for django_coverage_plugin.""" diff --git a/tests/test_settings.py b/tests/test_settings.py index 4be1636..5314051 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Settings tests for django_coverage_plugin.""" diff --git a/tests/test_simple.py b/tests/test_simple.py index a09ecb7..c4e326d 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Simple tests for django_coverage_plugin.""" diff --git a/tests/test_source.py b/tests/test_source.py index 6313504..e44c7ea 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt """Tests of template inheritance for django_coverage_plugin.""" diff --git a/tox.ini b/tox.ini index 08e6683..1aae1d5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt +# For details: https://github.com/coveragepy/django_coverage_plugin/blob/main/NOTICE.txt # tox configuration for django_coverage_plugin. # From 0bfaf9800748d8aa0b37be91c1f98637af0efadb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 9 Nov 2025 11:43:04 -0500 Subject: [PATCH 26/32] update to new repo location --- README.rst | 18 +++++++++--------- pyproject.toml | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index b735872..d6ef68f 100644 --- a/README.rst +++ b/README.rst @@ -191,7 +191,7 @@ ignore_errors=True`` (`issue 78`_). When using ``source=.``, an existing coverage HTML report directory would be found and believed to be unmeasured HTML template files. This is now fixed. -.. _issue 78: https://github.com/nedbat/django_coverage_plugin/issues/78 +.. _issue 78: https://github.com/coveragepy/django_coverage_plugin/issues/78 v2.0.1 — 2021-10-06 @@ -214,9 +214,9 @@ case-sensitively, causing templates to be missed (`issue 46`_). Fix an issue (`issue 63`_) where tag libraries can't be found if imported during test collection. Thanks to Daniel Izquierdo for the fix. -.. _issue 46: https://github.com/nedbat/django_coverage_plugin/issues/46 -.. _issue 60: https://github.com/nedbat/django_coverage_plugin/issues/60 -.. _issue 63: https://github.com/nedbat/django_coverage_plugin/issues/63 +.. _issue 46: https://github.com/coveragepy/django_coverage_plugin/issues/46 +.. _issue 60: https://github.com/coveragepy/django_coverage_plugin/issues/60 +.. _issue 63: https://github.com/coveragepy/django_coverage_plugin/issues/63 v1.8.0 — 2020-01-23 ------------------- @@ -266,7 +266,7 @@ v1.4.2 — 2017-02-06 Fixes another instance of `issue 32`_, which was the result of an initialization order problem. -.. _issue 32: https://github.com/nedbat/django_coverage_plugin/issues/32 +.. _issue 32: https://github.com/coveragepy/django_coverage_plugin/issues/32 v1.4.1 — 2017-01-25 @@ -288,8 +288,8 @@ Only the ``django.template.backends.django.DjangoTemplates`` template engine is supported, and it must be configured with ``['OPTIONS']['debug'] = True``. Fixes `issue 27`_. -.. _issue 28: https://github.com/nedbat/django_coverage_plugin/issues/28 -.. _issue 27: https://github.com/nedbat/django_coverage_plugin/issues/27 +.. _issue 28: https://github.com/coveragepy/django_coverage_plugin/issues/28 +.. _issue 27: https://github.com/coveragepy/django_coverage_plugin/issues/27 @@ -299,7 +299,7 @@ v1.3.1 — 2016-06-02 Settings are read slightly differently, so as to not interfere with programs that don't need settings. Fixes `issue 18`_. -.. _issue 18: https://github.com/nedbat/django_coverage_plugin/issues/18 +.. _issue 18: https://github.com/coveragepy/django_coverage_plugin/issues/18 @@ -335,7 +335,7 @@ plugin, and fixes `issue 17`_. Potential Django 1.9 support is included, but the patch to Django hasn't been applied yet. -.. _issue 17: https://github.com/nedbat/django_coverage_plugin/issues/17 +.. _issue 17: https://github.com/coveragepy/django_coverage_plugin/issues/17 diff --git a/pyproject.toml b/pyproject.toml index 6bc35c3..0c7292f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,9 +40,9 @@ dependencies = [ dynamic = ["version"] [project.urls] -"Homepage" = "https://github.com/nedbat/django_coverage_plugin" -"Bug Tracker" = "https://github.com/nedbat/django_coverage_plugin/issues" -"Source" = "https://github.com/nedbat/django_coverage_plugin" +"Homepage" = "https://github.com/coveragepy/django_coverage_plugin" +"Bug Tracker" = "https://github.com/coveragepy/django_coverage_plugin/issues" +"Source" = "https://github.com/coveragepy/django_coverage_plugin" [tool.setuptools.dynamic] version = {attr = "django_coverage_plugin.__version__"} From c431828420fc5192b1fd0a1371845f2e4f438910 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 6 Jan 2026 06:13:51 -0500 Subject: [PATCH 27/32] fully pinned github actions --- .github/dependabot.yml | 21 +++++++++++++++++++++ .github/workflows/tests.yml | 8 ++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f1566d8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +# From: +# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/keeping-your-actions-up-to-date-with-dependabot +# Set update schedule for GitHub Actions + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions once a week + interval: "weekly" + day: "sunday" + cooldown: + # https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns + default-days: 7 + groups: + action-dependencies: + patterns: + - "*" + commit-message: + prefix: "chore" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4deb5b5..582230e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,12 +50,12 @@ jobs: steps: - name: "Check out the repo" - uses: "actions/checkout@v4" + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false - name: "Set up Python" - uses: "actions/setup-python@v5" + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: "${{ matrix.python-version }}" allow-prereleases: true @@ -87,12 +87,12 @@ jobs: steps: - name: "Check out the repo" - uses: "actions/checkout@v4" + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false - name: "Set up Python" - uses: "actions/setup-python@v5" + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: "3.10" From 398195014d87acb292d1ea5f51014b11f8474403 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 25 Jan 2026 15:09:59 -0500 Subject: [PATCH 28/32] chore: bump actions/checkout in the action-dependencies group (#105) Bumps the action-dependencies group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 6.0.1 to 6.0.2 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8e8c483db84b4bee98b60c0593521ed34d9990e8...de0fac2e4500dabe0009e67214ff5f5447ce83dd) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 6.0.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: action-dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 582230e..54b623a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,7 +50,7 @@ jobs: steps: - name: "Check out the repo" - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false @@ -87,7 +87,7 @@ jobs: steps: - name: "Check out the repo" - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false From 53d114ac6082fb3fcd97c5cf0c4d634d395fe7f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 06:26:19 -0500 Subject: [PATCH 29/32] chore: bump actions/setup-python in the action-dependencies group (#106) Bumps the action-dependencies group with 1 update: [actions/setup-python](https://github.com/actions/setup-python). Updates `actions/setup-python` from 6.1.0 to 6.2.0 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/83679a892e2d95755f2dac6acb0bfd1e9ac5d548...a309ff8b426b58ec0e2a45f0f869d46889d02405) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: 6.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: action-dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 54b623a..e164594 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,7 +55,7 @@ jobs: persist-credentials: false - name: "Set up Python" - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: python-version: "${{ matrix.python-version }}" allow-prereleases: true @@ -92,7 +92,7 @@ jobs: persist-credentials: false - name: "Set up Python" - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: python-version: "3.10" From e70bcf510ba7d270c6c02c73ff0e2a3278289684 Mon Sep 17 00:00:00 2001 From: Becky Smith Date: Wed, 21 Feb 2024 14:00:33 +0000 Subject: [PATCH 30/32] Config option to exclude block tags by regex --- README.rst | 16 +++++++++------- django_coverage_plugin/plugin.py | 25 +++++++++++++++++++++++-- tests/test_simple.py | 27 +++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index d6ef68f..7a8bb08 100644 --- a/README.rst +++ b/README.rst @@ -97,15 +97,17 @@ extensions if you like:: [django_coverage_plugin] template_extensions = html, txt, tex, email -If you use ``pyproject.toml`` for tool configuration use:: +To exclude specific individual lines in a template, use the usual +``# pragma: no cover`` notation inline. Template tags can also be excluded using regexes to +match the block content; for example, to exclude a custom template tag +``{% my_tag ... %}``, use:: - [tool.coverage.run] - plugins = [ - 'django_coverage_plugin', - ] + [run] + plugins = django_coverage_plugin + + [django_coverage_plugin] + exclude_blocks = ["my_tag.+"] - [tool.coverage.django_coverage_plugin] - template_extensions = 'html, txt, tex, email' Caveats ~~~~~~~ diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 13e9c41..6e6dac0 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -10,6 +10,7 @@ import django import django.template from coverage.exceptions import NoSource +from coverage.misc import join_regex from django.template.base import Lexer, NodeList, Template, TextNode, TokenType from django.template.defaulttags import VerbatimNode from django.templatetags.i18n import BlockTranslateNode @@ -116,6 +117,8 @@ class DjangoTemplatePlugin( def __init__(self, options): extensions = options.get("template_extensions", "html,htm,txt") self.extensions = [e.strip() for e in extensions.split(",")] + + self.exclude_blocks = options.get("exclude_blocks") self.debug_checked = False @@ -151,7 +154,7 @@ def file_tracer(self, filename): return None def file_reporter(self, filename): - return FileReporter(filename) + return FileReporter(filename, self.exclude_blocks) def find_executable_files(self, src_dir): # We're only interested in files that look like reasonable HTML @@ -259,10 +262,16 @@ def get_line_map(self, filename): class FileReporter(coverage.plugin.FileReporter): - def __init__(self, filename): + def __init__(self, filename, exclude_blocks): super().__init__(filename) # TODO: html filenames are absolute. + if exclude_blocks: + self.exclude_blocks_regex = re.compile(join_regex(exclude_blocks)) + else: + self.exclude_blocks_regex = None + self._excluded = set() + self._source = None def source(self): @@ -318,6 +327,12 @@ def lines(self): # In an inheriting template, ignore all tags outside of # blocks. continue + + # Ignore any block token content that has been explcitly + # excluded in config + if self.exclude_block_token(token): + self._excluded.add(token.lineno) + continue if token.contents == "comment": comment = True @@ -356,6 +371,12 @@ def lines(self): return source_lines + def excluded_lines(self): + return self._excluded + + def exclude_block_token(self, token): + if self.exclude_blocks_regex: + return self.exclude_blocks_regex.search(token.contents) def running_sum(seq): total = 0 diff --git a/tests/test_simple.py b/tests/test_simple.py index c4e326d..2ae1b3c 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -264,3 +264,30 @@ def test_with_branch_enabled(self): ) self.assertEqual(text, 'Hello\nWorld\n\nGoodbye') self.assert_analysis([1, 2, 3, 4]) + + +class ExcludeTest(DjangoPluginTestCase): + """Tests of excluding block tokens by regex.""" + + def test_exclude_block(self): + self.make_template("""\ + First + {% with foo='bar' %} + {{ foo }} + {% endwith %} + Last + """) + text = self.run_django_coverage() + self.assertEqual(text, "First\n\n bar\n\nLast\n") + self.assert_analysis([1, 2, 3, 5]) + + self.make_file(".coveragerc", """\ + [run] + plugins = django_coverage_plugin + [django_coverage_plugin] + exclude_blocks = [".+foo.+"] + """) + + text = self.run_django_coverage() + self.assertEqual(text, "First\n\n bar\n\nLast\n") + self.assert_analysis([1, 3, 5]) From 5299a7552fb9d4499ced2e8e37ccea9e08d5f8a8 Mon Sep 17 00:00:00 2001 From: Becky Smith Date: Wed, 21 Feb 2024 14:00:33 +0000 Subject: [PATCH 31/32] Update README --- README.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 7a8bb08..559269c 100644 --- a/README.rst +++ b/README.rst @@ -97,10 +97,8 @@ extensions if you like:: [django_coverage_plugin] template_extensions = html, txt, tex, email -To exclude specific individual lines in a template, use the usual -``# pragma: no cover`` notation inline. Template tags can also be excluded using regexes to -match the block content; for example, to exclude a custom template tag -``{% my_tag ... %}``, use:: +Block tags can be excluded using regexes to match the block content; +for example, to exclude a custom template tag ``{% my_tag ... %}``, use:: [run] plugins = django_coverage_plugin From 79caa857e3f9a3904b05ca1429e87589b37c7c2e Mon Sep 17 00:00:00 2001 From: Becky Smith Date: Wed, 11 Feb 2026 17:01:57 +0000 Subject: [PATCH 32/32] fix linting --- django_coverage_plugin/plugin.py | 5 +++-- tests/test_simple.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 6e6dac0..a7bce63 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -117,7 +117,7 @@ class DjangoTemplatePlugin( def __init__(self, options): extensions = options.get("template_extensions", "html,htm,txt") self.extensions = [e.strip() for e in extensions.split(",")] - + self.exclude_blocks = options.get("exclude_blocks") self.debug_checked = False @@ -327,7 +327,7 @@ def lines(self): # In an inheriting template, ignore all tags outside of # blocks. continue - + # Ignore any block token content that has been explcitly # excluded in config if self.exclude_block_token(token): @@ -378,6 +378,7 @@ def exclude_block_token(self, token): if self.exclude_blocks_regex: return self.exclude_blocks_regex.search(token.contents) + def running_sum(seq): total = 0 for num in seq: diff --git a/tests/test_simple.py b/tests/test_simple.py index 2ae1b3c..ccb3e84 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -287,7 +287,7 @@ def test_exclude_block(self): [django_coverage_plugin] exclude_blocks = [".+foo.+"] """) - + text = self.run_django_coverage() self.assertEqual(text, "First\n\n bar\n\nLast\n") self.assert_analysis([1, 3, 5])