From efb1aac971c130a1987d9b9593b73a820278307d Mon Sep 17 00:00:00 2001 From: Alex Nathanail Date: Thu, 28 May 2020 18:13:49 +0100 Subject: [PATCH 01/90] Add note about template debug setting to README --- README.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.rst b/README.rst index 0b68a8e..29432ee 100644 --- a/README.rst +++ b/README.rst @@ -51,6 +51,20 @@ the plugin to identify untested templates. If you get a :code:`django.core.exceptions.ImproperlyConfigured` error, you need to set the :code:`DJANGO_SETTINGS_MODULE` environment variable. +If you get :code:`django_coverage_plugin.plugin.DjangoTemplatePluginException: Template debugging must be enabled in settings`, change your TEMPLATES setting: + +.. code-block:: python + + DEBUG = True + + TEMPLATES = [ + { + ... + 'OPTIONS': { + 'debug': DEBUG, + }, + }, + ] Configuration ~~~~~~~~~~~~~ From 7fa66b18f18c79d66ef07032784610b855b1849f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 17 May 2021 07:52:00 -0400 Subject: [PATCH 02/90] Drop support for Python 3.4 and 3.5 --- HISTORY.rst | 6 ++++++ tox.ini | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 7470bd0..6ea7f16 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,12 @@ History ======= +Unreleased +---------- + +Drop support for Python 3.4 and 3.5. + + v1.8.0 --- 2020-01-23 --------------------- diff --git a/tox.ini b/tox.ini index 7af5133..8da10a5 100644 --- a/tox.ini +++ b/tox.ini @@ -15,8 +15,6 @@ [tox] envlist = py27-django{18,19,110,111}, - py34-django{18,19,110,111,20}, - py35-django{18,19,110,111,20,21,22}, py36-django{18,19,110,111,20,21,22,30,tip}, py37-django{20,21,22,30,tip}, py38-django{22,30,tip}, From 09fb4101caeb4455d5efaafeace8096956249b1f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 17 May 2021 07:52:41 -0400 Subject: [PATCH 03/90] Update the Django versions we test with --- tox.ini | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 8da10a5..9483944 100644 --- a/tox.ini +++ b/tox.ini @@ -15,9 +15,10 @@ [tox] envlist = py27-django{18,19,110,111}, - py36-django{18,19,110,111,20,21,22,30,tip}, - py37-django{20,21,22,30,tip}, - py38-django{22,30,tip}, + py36-django{18,19,110,111,20,21,22,30,31,32}, + py37-django{20,21,22,30,31,32}, + py38-django{22,30,31,32,tip}, + py39-django{22,30,31,32,tip}, check,pkgcheck,doc [testenv] @@ -31,7 +32,9 @@ deps = django21: Django>=2.1,<2.2 django22: Django>=2.2,<3.0 django30: Django>=3.0,<3.1 - djangotip: https://github.com/django/django/archive/master.tar.gz + django31: Django>=3.1,<3.2 + django32: Django>=3.2,<4.0 + djangotip: https://github.com/django/django/archive/main.tar.gz commands = python -c "import tests.banner" From 2d5347344576e49e0047f79522f4dfb395c477d3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 17 May 2021 07:53:06 -0400 Subject: [PATCH 04/90] Correct a flake8 concern django_coverage_plugin/plugin.py:390:32: E741 ambiguous variable name 'l' --- django_coverage_plugin/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index e777f4f..c031e33 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -387,7 +387,7 @@ def running_sum(seq): def make_line_map(text): - line_lengths = [len(l) for l in text.splitlines(True)] + line_lengths = [len(line) for line in text.splitlines(True)] line_map = list(running_sum(line_lengths)) return line_map From 391a5fad049ff9789bd5407454b1d811f0563c28 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 17 May 2021 08:02:00 -0400 Subject: [PATCH 05/90] Keep isort happy --- django_coverage_plugin/__init__.py | 2 +- django_coverage_plugin/plugin.py | 5 ++++- tox.ini | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index 5150b20..04b4b90 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -3,8 +3,8 @@ """Django Template Coverage Plugin""" +from .plugin import DjangoTemplatePluginException # noqa from .plugin import DjangoTemplatePlugin -from .plugin import DjangoTemplatePluginException # noqa def coverage_init(reg, options): diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index c031e33..1c4511f 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -25,7 +25,10 @@ def _token_name(token_type): except ImportError: # Django <2.1 uses separate constants for token types from django.template.base import ( - TOKEN_BLOCK, TOKEN_MAPPING, TOKEN_TEXT, TOKEN_VAR + TOKEN_BLOCK, + TOKEN_MAPPING, + TOKEN_TEXT, + TOKEN_VAR, ) class TokenType: diff --git a/tox.ini b/tox.ini index 9483944..25f5660 100644 --- a/tox.ini +++ b/tox.ini @@ -51,7 +51,7 @@ deps = commands = flake8 --max-line-length=100 setup.py django_coverage_plugin tests setup.py - isort --verbose --check-only --diff --recursive django_coverage_plugin tests setup.py + isort --check-only --diff django_coverage_plugin tests setup.py [testenv:pkgcheck] skip_install = true From b503060fe705c53643fd00c7ec026bf47bbf2f87 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 17 May 2021 08:19:03 -0400 Subject: [PATCH 06/90] Django 4.0 dropped django.conf.urls.url --- tests/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 038b3ad..2d2b590 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,7 +5,10 @@ # Define URLs here so we can use ROOT_URLCONF="tests" -from django.conf.urls import url +try: + from django.urls import re_path +except ImportError: + from django.conf.urls import url as re_path def index(request): @@ -14,5 +17,5 @@ def index(request): urlpatterns = [ - url(r'^home$', index, name='index'), + re_path(r'^home$', index, name='index'), ] From c9b94d1e8927ce5284850ab5e4d5e6a4e7318d36 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 17 May 2021 08:31:58 -0400 Subject: [PATCH 07/90] Django 4.0 dropped ifequal and ifnotequal --- tests/test_flow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_flow.py b/tests/test_flow.py index 172e0e4..2a00709 100644 --- a/tests/test_flow.py +++ b/tests/test_flow.py @@ -5,7 +5,7 @@ import textwrap -from .plugin_test import DjangoPluginTestCase, squashed +from .plugin_test import DjangoPluginTestCase, django_stop_before, squashed class IfTest(DjangoPluginTestCase): @@ -173,6 +173,7 @@ def test_ifchanged_variable(self): self.assert_analysis([1, 2, 3, 4, 5]) +@django_stop_before(4, 0) class IfEqualTest(DjangoPluginTestCase): def test_ifequal(self): From 28735498f99d5f0b7a6ca1febf8b2a26fd2cf07e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 May 2021 16:10:03 -0400 Subject: [PATCH 08/90] Switch to GitHub Actions and pytest --- .github/workflows/tests.yml | 68 +++++++++++++++++++++++++++++++++++++ .travis.yml | 11 ------ tox.ini | 11 +++++- 3 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..77f6c60 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,68 @@ +# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt + +name: "Tests" + +on: + push: + pull_request: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + tests: + name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}" + runs-on: "${{ matrix.os }}" + + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + python-version: + # When changing this list, be sure to check the [gh-actions] list in + # tox.ini so that tox will run properly. + - "2.7" + - "3.6" + - "3.7" + - "3.8" + - "3.9" + exclude: + # Windows 2.7 doesn't work because Microsoft removed stuff we needed. + - os: windows-latest + python-version: "2.7" + fail-fast: false + + steps: + - name: "Check out the repo" + uses: "actions/checkout@v2" + + - name: "Set up Python" + uses: "actions/setup-python@v2" + with: + python-version: "${{ matrix.python-version }}" + + - name: "Install dependencies" + run: | + set -xe + python -VV + python -m site + python -m pip install -r requirements.txt + python -m pip install tox-gh-actions + + - name: "Run tox for ${{ matrix.python-version }}" + run: | + # GitHub Actions on Windows sets TEMP to a shortname, and HOME to a + # longname. Eventually, filename comparisons fail because of the + # difference. Fix $TEMP. + echo $TEMP + if [ "$RUNNER_OS" == "Windows" ]; then + export TMP=$HOME\\AppData\\Local\\Temp + export TEMP=$HOME\\AppData\\Local\\Temp + fi + echo $TEMP + python -m tox diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9db7c78..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -sudo: false -language: python -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" - - "3.7" - - "3.8" -install: pip install tox-travis -script: tox diff --git a/tox.ini b/tox.ini index 25f5660..a48e198 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,7 @@ envlist = [testenv] deps = + pytest unittest-mixins==1.6 django18: Django>=1.8,<1.9 django19: Django>=1.9,<1.10 @@ -38,7 +39,7 @@ deps = commands = python -c "import tests.banner" - python -m unittest {posargs:discover -b} + python -m pytest {posargs} usedevelop = True @@ -70,3 +71,11 @@ deps = commands = rst2html.py --strict README.rst /tmp/django_coverage_plugin_README.html + +[gh-actions] +python = + 2.7: py27 + 3.6: py36 + 3.7: py37 + 3.8: py38 + 3.9: py39 From d287548ed6d281c28c4cc553bb4fdf3b5a362ea1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 May 2021 18:04:32 -0400 Subject: [PATCH 09/90] fix: compare filenames with platform-appropriate case sensitivity Fixes issue #46. --- HISTORY.rst | 4 ++++ django_coverage_plugin/plugin.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6ea7f16..ed2fbda 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,10 @@ Unreleased Drop support for Python 3.4 and 3.5. +Fixed an issue on Windows where file names were being compared +case-sensitively, causing templates to be missed (`issue 46`_). + +.. _issue 46: https://github.com/nedbat/django_coverage_plugin/issues/46 v1.8.0 --- 2020-01-23 --------------------- diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 1c4511f..a033869 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -156,9 +156,9 @@ class DjangoTemplatePlugin( def __init__(self): self.debug_checked = False - self.django_template_dir = os.path.realpath( + self.django_template_dir = os.path.normcase(os.path.realpath( os.path.dirname(django.template.__file__) - ) + )) self.source_map = {} @@ -175,7 +175,7 @@ def sys_info(self): ] def file_tracer(self, filename): - if filename.startswith(self.django_template_dir): + if os.path.normcase(filename).startswith(self.django_template_dir): if not self.debug_checked: # Keep calling check_debug until it returns True, which it # will only do after settings have been configured From c6e1799b12d9ee0c7138ae3d5d1d8dcf24cdcc15 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 May 2021 18:53:14 -0400 Subject: [PATCH 10/90] test: use an OS-agnostic way to allow all {% ssi %} --- tests/plugin_test.py | 2 +- tests/test_extends.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/plugin_test.py b/tests/plugin_test.py index e8ab006..ca2fefe 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -52,7 +52,7 @@ def test_settings(): if django.VERSION < (1, 10): # for {% ssi %} - the_settings['TEMPLATES'][0]['OPTIONS']['allowed_include_roots'] = ['/'] + the_settings['TEMPLATES'][0]['OPTIONS']['allowed_include_roots'] = [""] return the_settings diff --git a/tests/test_extends.py b/tests/test_extends.py index cfa3af3..46ff661 100644 --- a/tests/test_extends.py +++ b/tests/test_extends.py @@ -3,6 +3,8 @@ """Tests of template inheritance for django_coverage_plugin.""" +import os.path + from .plugin_test import DjangoPluginTestCase, django_stop_before @@ -170,7 +172,10 @@ def test_ssi_unparsed(self): self.assert_analysis([1, 2, 3], name="outer.html") self.assertEqual( set(self.measured_files()), - set(["templates/outer.html", "templates/nested.html"]) + set([ + os.path.join("templates", "outer.html"), + os.path.join("templates", "nested.html"), + ]) ) def test_ssi_parsed(self): @@ -190,5 +195,8 @@ def test_ssi_parsed(self): self.assert_analysis([1, 2, 3], name="outer.html") self.assertEqual( set(self.measured_files()), - set(["templates/outer.html", "templates/nested.html"]) + set([ + os.path.join("templates", "outer.html"), + os.path.join("templates", "nested.html"), + ]) ) From c4fe31f1ed963f47af0673887439ba9ca399f0f0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 May 2021 19:02:54 -0400 Subject: [PATCH 11/90] build: .editorconfig files help with editing details --- .editorconfig | 38 ++++++++++++++++++++++++++++++++++++++ MANIFEST.in | 1 + 2 files changed, 39 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..88200b6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,38 @@ +# 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 + +# This file is for unifying the coding style for different editors and IDEs. +# More information at http://EditorConfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 80 +trim_trailing_whitespace = true + +[*.py] +max_line_length = 100 + +[*.yml] +indent_size = 2 + +[*.rst] +max_line_length = 79 + +[Makefile] +indent_style = tab +indent_size = 8 + +[*,cover] +trim_trailing_whitespace = false + +[*.diff] +trim_trailing_whitespace = false + +[.git/*] +trim_trailing_whitespace = false diff --git a/MANIFEST.in b/MANIFEST.in index 200b65c..7be7bf2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,7 @@ exclude howto.txt exclude Makefile exclude requirements.txt exclude tox.ini +exclude .editorconfig include AUTHORS.txt include HISTORY.rst include LICENSE.txt From 504ca59677af71a173f0fb4bd4c897f3b7d43165 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 May 2021 19:24:41 -0400 Subject: [PATCH 12/90] build: add the check tox environments to CI --- .github/workflows/tests.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 77f6c60..1674c05 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -66,3 +66,35 @@ jobs: fi echo $TEMP python -m tox + + checks: + name: "Quality checks" + runs-on: "ubuntu-latest" + + steps: + - name: "Check out the repo" + uses: "actions/checkout@v2" + + - name: "Set up Python" + uses: "actions/setup-python@v2" + with: + python-version: "3.8" + + - name: "Install dependencies" + run: | + set -xe + python -VV + python -m site + python -m pip install -r requirements.txt + + - name: "Run check" + run: | + python -m tox -e check + + - name: "Run pkgcheck" + run: | + python -m tox -e pkgcheck + + - name: "Run doc" + run: | + python -m tox -e doc From 6622791245b293d7156c48ca3dcb464be36bedcc Mon Sep 17 00:00:00 2001 From: Daniel Izquierdo Date: Wed, 19 Jun 2019 13:48:33 +0900 Subject: [PATCH 13/90] Fix tags missing when imported during collection (cherry picked from commit 06d4dd873877b7e6b453c30f4041b3c872781656) --- django_coverage_plugin/plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index a033869..3b380da 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -78,6 +78,8 @@ def check_debug(): return False if not hasattr(django.template.backends.django, "DjangoTemplates"): raise DjangoTemplatePluginException("Can't use non-Django templates.") + if not django.template.engines._engines: + return False for engine in django.template.engines.all(): if not isinstance(engine, django.template.backends.django.DjangoTemplates): From 3e682cf7f152f81ddce2ae76852542b51115b334 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 24 May 2021 21:50:09 -0400 Subject: [PATCH 14/90] Update history for #63 --- HISTORY.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index ed2fbda..6033c74 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,10 +7,14 @@ Unreleased Drop support for Python 3.4 and 3.5. -Fixed an issue on Windows where file names were being compared +Fix an issue on Windows where file names were being compared 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 63: https://github.com/nedbat/django_coverage_plugin/issues/63 v1.8.0 --- 2020-01-23 --------------------- From 3b7972fd4087612f26894e564ee902e951392c24 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 31 May 2021 07:20:18 -0400 Subject: [PATCH 15/90] doc: explain more about the TEMPLATES.OPTIONS.debug setting --- README.rst | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 29432ee..43dc170 100644 --- a/README.rst +++ b/README.rst @@ -26,11 +26,11 @@ Django Template Coverage.py Plugin A `coverage.py`_ plugin to measure test coverage of Django templates. -Supported Python versions: 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8. +Supported Python versions: 2.7, 3.6, 3.7, 3.8 and 3.9. -Supported Django versions: 1.8, 1.11, 2.0, 2.1, 2.2 and 3.0. +Supported Django versions: 1.8, 1.11, 2.x and 3.x. -Supported coverage.py version 4.x or 5.x. +Supported coverage.py versions: 4.x or higher. The plugin is pip installable:: @@ -39,8 +39,7 @@ The plugin is pip installable:: To run it, add this setting to your ``.coveragerc`` file:: [run] - plugins = - django_coverage_plugin + plugins = django_coverage_plugin Then run your tests under `coverage.py`_. @@ -51,21 +50,24 @@ the plugin to identify untested templates. If you get a :code:`django.core.exceptions.ImproperlyConfigured` error, you need to set the :code:`DJANGO_SETTINGS_MODULE` environment variable. -If you get :code:`django_coverage_plugin.plugin.DjangoTemplatePluginException: Template debugging must be enabled in settings`, change your TEMPLATES setting: +Template coverage only works if your Django templates have debugging enabled. +If you get :code:`django_coverage_plugin.plugin.DjangoTemplatePluginException: +Template debugging must be enabled in settings`, or if no templates get +measured, make sure you have :code:`TEMPLATES.OPTIONS.debug` set to True in +your settings file: .. code-block:: python - DEBUG = True - TEMPLATES = [ { ... 'OPTIONS': { - 'debug': DEBUG, + 'debug': True, }, }, ] + Configuration ~~~~~~~~~~~~~ From 7db66a219e95a8fb6ae69d181caea52279356bf2 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 31 May 2021 08:23:48 -0400 Subject: [PATCH 16/90] test: suppress warnings we don't need to see --- setup.cfg | 10 ++++++++++ tests/conftest.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 setup.cfg create mode 100644 tests/conftest.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..679b318 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,10 @@ +# 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 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..0852e87 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,38 @@ +# 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 + +""" +Pytest auto configuration. + +This module is run automatically by pytest, to define and enable fixtures. +""" + +import re +import warnings + +import django.utils.deprecation +import pytest + + +@pytest.fixture(autouse=True) +def set_warnings(): + """Configure warnings to show while running tests.""" + warnings.simplefilter("default") + warnings.simplefilter("once", DeprecationWarning) + + # Warnings to suppress: + # How come these warnings are successfully suppressed here, but not in setup.cfg?? + + # We know we do tricky things with Django settings, don't warn us about it. + warnings.filterwarnings( + "ignore", + category=UserWarning, + message=r"Overriding setting DATABASES can lead to unexpected behavior.", + ) + + # Django has warnings like RemovedInDjango40Warning. We use features that are going to be + # deprecated, so we don't need to see those warnings. But the specific warning classes change + # in every release. Find them and ignore them. + for name, obj in vars(django.utils.deprecation).items(): + if re.match(r"RemovedInDjango\d+Warning", name): + warnings.filterwarnings("ignore", category=obj) From 97c7d1f380491a4a8ec5be90ace034e9faef23c1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 31 May 2021 08:35:56 -0400 Subject: [PATCH 17/90] build: use twine to check the package --- setup.py | 1 + tox.ini | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2529896..da09266 100644 --- a/setup.py +++ b/setup.py @@ -62,6 +62,7 @@ def read(*names, **kwargs): re.M | re.S, ).sub('', 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', diff --git a/tox.ini b/tox.ini index a48e198..bfe85fb 100644 --- a/tox.ini +++ b/tox.ini @@ -60,9 +60,11 @@ deps = docutils check-manifest readme-renderer + twine commands = - python setup.py check --strict --metadata --restructuredtext + python setup.py -q sdist + twine check dist/* check-manifest {toxinidir} [testenv:doc] From 33a51127f3562a59c5a29fa2d22cd10e9e3bff46 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 07:00:42 -0400 Subject: [PATCH 18/90] build: don't test on non-LTS versions of Django --- tox.ini | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tox.ini b/tox.ini index bfe85fb..3cfcf1e 100644 --- a/tox.ini +++ b/tox.ini @@ -14,11 +14,11 @@ [tox] envlist = - py27-django{18,19,110,111}, - py36-django{18,19,110,111,20,21,22,30,31,32}, - py37-django{20,21,22,30,31,32}, - py38-django{22,30,31,32,tip}, - py39-django{22,30,31,32,tip}, + py27-django{18,111}, + py36-django{18,111,22,32}, + py37-django{22,32}, + py38-django{22,32,tip}, + py39-django{22,32,tip}, check,pkgcheck,doc [testenv] @@ -26,14 +26,8 @@ deps = pytest unittest-mixins==1.6 django18: Django>=1.8,<1.9 - django19: Django>=1.9,<1.10 - django110: Django>=1.10,<1.11 django111: Django>=1.11,<2.0 - django20: Django>=2.0,<2.1 - django21: Django>=2.1,<2.2 django22: Django>=2.2,<3.0 - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 django32: Django>=3.2,<4.0 djangotip: https://github.com/django/django/archive/main.tar.gz From 27d4fc8a4bcf2f60aa1cc89246b8b4a87e5a694a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 07:06:41 -0400 Subject: [PATCH 19/90] build: make help, and a quieter test target --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2aa9a8e..159cc4f 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,14 @@ # Makefile for django_coverage_plugin -default: - @echo "* No default action *" +help: ## Show this help. + @echo "Available targets:" + @grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf " %-26s%s\n", $$1, $$2}' -test: - tox +test: ## Run all the tests. + tox -q -- -q -clean: +clean: ## Remove non-source files. -rm -rf *.egg-info -rm -rf build dist -rm -f *.pyc */*.pyc */*/*.pyc */*/*/*.pyc */*/*/*/*.pyc */*/*/*/*/*.pyc @@ -20,7 +21,7 @@ clean: -rm -f .coverage .coverage.* coverage.xml -rm -f setuptools-*.egg distribute-*.egg distribute-*.tar.gz -sterile: clean +sterile: clean ## Remove all non-controlled content, even if expensive. -rm -rf .tox* SDIST_CMD = python setup.py sdist --formats=gztar From 3f7d993ad25b60017014c82514a53339309ab8e9 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 07:20:29 -0400 Subject: [PATCH 20/90] fix: Django 4.0dev optimized text rendering. Adapt. In https://github.com/django/django/commit/7f6a41d3d915feb01acfa08b2b936d1199d, TextNode got its own implementation of the internal render_annotated method. We need to notice those calls in addition to render calls. --- django_coverage_plugin/plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 3b380da..ac36681 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -203,8 +203,12 @@ def find_executable_files(self, src_dir): def has_dynamic_source_filename(self): return True + # "render" is the public method, but "render_annotated" is an internal + # method sometimes implemented directly on nodes. + RENDER_METHODS = {"render", "render_annotated"} + def dynamic_source_filename(self, filename, frame): - if frame.f_code.co_name != 'render': + if frame.f_code.co_name not in self.RENDER_METHODS: return None if 0: @@ -219,7 +223,7 @@ def dynamic_source_filename(self, filename, frame): return None def line_number_range(self, frame): - assert frame.f_code.co_name == 'render' + assert frame.f_code.co_name in self.RENDER_METHODS if 0: dump_frame(frame, label="line_number_range") From 578a2a92ce449e975c26e724b966e3c3e33b656c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 07:33:25 -0400 Subject: [PATCH 21/90] build: run the tests once a week even if our code hasn't changed. We use internal things that Django might change at any time, so we should run our tests even if our code hasn't changed. --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1674c05..367ad44 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,11 @@ on: push: pull_request: workflow_dispatch: + schedule: + # Since we test against the tip of Django development, run the tests once a + # week, Sundays at 6:00 UTC. + - cron: "0 6 * * 0" + defaults: run: From 3eee25dc4df06d2aec3a4a2742e0568ce73116ac Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 07:49:54 -0400 Subject: [PATCH 22/90] refactor: a more convenient assert for measured files --- tests/plugin_test.py | 12 +++++++++--- tests/test_extends.py | 18 ++---------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/tests/plugin_test.py b/tests/plugin_test.py index ca2fefe..dc171b7 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -176,9 +176,15 @@ def get_analysis(self, name=None): _, executable, _, missing, _ = analysis return executable, missing - def measured_files(self): - """Get the list of measured files, in relative form.""" - return [os.path.relpath(f) for f in self.cov.get_data().measured_files()] + def assert_measured_files(self, *template_files): + """Assert that the measured files are `template_files`. + + The names in `template_files` are the base names of files + in the templates directory. + """ + measured = {os.path.relpath(f) for f in self.cov.get_data().measured_files()} + expected = {os.path.join("templates", f) for f in template_files} + self.assertEqual(measured, expected) def assert_analysis(self, executable, missing=None, name=None): """Assert that the analysis for `name` is right.""" diff --git a/tests/test_extends.py b/tests/test_extends.py index 46ff661..a4922db 100644 --- a/tests/test_extends.py +++ b/tests/test_extends.py @@ -3,8 +3,6 @@ """Tests of template inheritance for django_coverage_plugin.""" -import os.path - from .plugin_test import DjangoPluginTestCase, django_stop_before @@ -170,13 +168,7 @@ def test_ssi_unparsed(self): text = self.run_django_coverage(name="outer.html", context={'a': 17}) self.assertEqual(text, "First\nInside {{ a }}\nJob\n\nLast\n") self.assert_analysis([1, 2, 3], name="outer.html") - self.assertEqual( - set(self.measured_files()), - set([ - os.path.join("templates", "outer.html"), - os.path.join("templates", "nested.html"), - ]) - ) + self.assert_measured_files("outer.html", "nested.html") def test_ssi_parsed(self): nested = self.make_template(name="nested.html", text="""\ @@ -193,10 +185,4 @@ def test_ssi_parsed(self): text = self.run_django_coverage(name="outer.html", context={'a': 17}) self.assertEqual(text, "First\nInside 17\nJob\n\nLast\n") self.assert_analysis([1, 2, 3], name="outer.html") - self.assertEqual( - set(self.measured_files()), - set([ - os.path.join("templates", "outer.html"), - os.path.join("templates", "nested.html"), - ]) - ) + self.assert_measured_files("outer.html", "nested.html") From 07970d93a1a0af9cb3621e3e698faf8b3ee58986 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 08:44:08 -0400 Subject: [PATCH 23/90] feat: template file extensions are configurable. #60 --- HISTORY.rst | 5 +++ README.rst | 11 +++++ django_coverage_plugin/__init__.py | 2 +- django_coverage_plugin/plugin.py | 15 ++++--- tests/test_source.py | 66 ++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 tests/test_source.py diff --git a/HISTORY.rst b/HISTORY.rst index 6033c74..40ae0ad 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,10 @@ Unreleased Drop support for Python 3.4 and 3.5. +A setting is available: ``template_extensions`` lets you set the file +extensions that will be considered when looking for unused templates +(requested in `issue 60`_). + Fix an issue on Windows where file names were being compared case-sensitively, causing templates to be missed (`issue 46`_). @@ -14,6 +18,7 @@ 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 v1.8.0 --- 2020-01-23 diff --git a/README.rst b/README.rst index 43dc170..e1d5b62 100644 --- a/README.rst +++ b/README.rst @@ -75,6 +75,17 @@ The Django template plugin uses some existing settings from your .coveragerc file. The ``source=``, ``include=``, and ``omit=`` options control what template files are included in the report. +The plugin can find unused template and include them in your results. By +default, it will look for files in your templates directory with an extension +of .html, .htm, or .txt. You can configure it to look for a different set of +extensions if you like:: + + [run] + plugins = django_coverage_plugin + + [django_coverage_plugin] + template_extensions = html, txt, tex, email + Caveats ~~~~~~~ diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index 04b4b90..e51c14e 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -8,4 +8,4 @@ def coverage_init(reg, options): - reg.add_file_tracer(DjangoTemplatePlugin()) + reg.add_file_tracer(DjangoTemplatePlugin(options)) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index ac36681..a3e4867 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -155,7 +155,10 @@ class DjangoTemplatePlugin( coverage.plugin.FileTracer, ): - def __init__(self): + def __init__(self, options): + extensions = options.get("template_extensions", "html,htm,txt") + self.extensions = [e.strip() for e in extensions.split(",")] + self.debug_checked = False self.django_template_dir = os.path.normcase(os.path.realpath( @@ -190,12 +193,14 @@ def file_reporter(self, filename): return FileReporter(filename) def find_executable_files(self, src_dir): + # We're only interested in files that look like reasonable HTML + # files: Must end with one of our extensions, and must not have + # funny characters that probably mean they are editor junk. + rx = r"^[^.#~!$@%^&*()+=,]+\.(" + "|".join(self.extensions) + r")$" + for (dirpath, dirnames, filenames) in os.walk(src_dir): for filename in filenames: - # We're only interested in files that look like reasonable HTML - # files: Must end with .htm or .html, and must not have certain - # funny characters that probably mean they are editor junk. - if re.match(r"^[^.#~!$@%^&*()+=,]+\.html?$", filename): + if re.search(rx, filename): yield os.path.join(dirpath, filename) # --- FileTracer methods diff --git a/tests/test_source.py b/tests/test_source.py new file mode 100644 index 0000000..76992d3 --- /dev/null +++ b/tests/test_source.py @@ -0,0 +1,66 @@ +# 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 + +"""Tests of template inheritance for django_coverage_plugin.""" + +from .plugin_test import DjangoPluginTestCase + + +class FindSourceTest(DjangoPluginTestCase): + + def test_finding_source(self): + # This is a template that is rendered. + self.make_template(name="main.html", text="Hello") + # These are templates that aren't rendered, but are considered renderable. + self.make_template(name="unused.html", text="Not used") + self.make_template(name="unused.htm", text="Not used") + self.make_template(name="unused.txt", text="Not used") + # These are things left behind by an editor. + self.make_template(name="~unused.html", text="junk") + self.make_template(name="unused=.html", text="junk") + self.make_template(name="unused.html,", text="junk") + # This is some other file format we don't recognize. + self.make_template(name="phd.tex", text="Too complicated to read") + + text = self.run_django_coverage(name="main.html") + self.assertEqual(text, "Hello") + + # The rendered file has data, and was measured. + self.assert_analysis([1], name="main.html") + # The unrendered files have data, and were not measured. + self.assert_analysis([1], name="unused.html", missing=[1]) + self.assert_analysis([1], name="unused.htm", missing=[1]) + self.assert_analysis([1], name="unused.txt", missing=[1]) + # The editor leave-behinds are not in the measured files. + self.assert_measured_files("main.html", "unused.html", "unused.htm", "unused.txt") + + def test_customized_extensions(self): + self.make_file(".coveragerc", """\ + [run] + plugins = django_coverage_plugin + [django_coverage_plugin] + template_extensions = html, tex + """) + # This is a template that is rendered. + self.make_template(name="main.html", text="Hello") + # These are templates that aren't rendered, but are considered renderable. + self.make_template(name="unused.html", text="Not used") + self.make_template(name="phd.tex", text="Too complicated to read") + # These are things left behind by an editor. + self.make_template(name="~unused.html", text="junk") + self.make_template(name="unused=.html", text="junk") + self.make_template(name="unused.html,", text="junk") + # This is some other file format we don't recognize. + self.make_template(name="unused.htm", text="Not used") + self.make_template(name="unused.txt", text="Not used") + + text = self.run_django_coverage(name="main.html") + self.assertEqual(text, "Hello") + + # The rendered file has data, and was measured. + self.assert_analysis([1], name="main.html") + # The unrendered files have data, and were not measured. + self.assert_analysis([1], name="unused.html", missing=[1]) + self.assert_analysis([1], name="phd.tex", missing=[1]) + # The editor leave-behinds are not in the measured files. + self.assert_measured_files("main.html", "unused.html", "phd.tex") From b630cb1ec33fb608711d4436d2d101cb45be08f4 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 19:06:36 -0400 Subject: [PATCH 24/90] docs: move history back into README We don't have a way to show people the HISTORY.rst file, so put it back into the README. --- HISTORY.rst | 157 --------------------------------------------------- MANIFEST.in | 1 - README.rst | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++ howto.txt | 1 - 4 files changed, 158 insertions(+), 159 deletions(-) delete mode 100644 HISTORY.rst diff --git a/HISTORY.rst b/HISTORY.rst deleted file mode 100644 index 40ae0ad..0000000 --- a/HISTORY.rst +++ /dev/null @@ -1,157 +0,0 @@ -======= -History -======= - -Unreleased ----------- - -Drop support for Python 3.4 and 3.5. - -A setting is available: ``template_extensions`` lets you set the file -extensions that will be considered when looking for unused templates -(requested in `issue 60`_). - -Fix an issue on Windows where file names were being compared -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 - -v1.8.0 --- 2020-01-23 ---------------------- - -Add support for: - -- Coverage 5 - -v1.7.0 --- 2020-01-16 ---------------------- - -Add support for: - -- Python 3.7 & 3.8 -- Django 2.2 & 3.0 - -v1.6.0 --- 2018-09-04 ---------------------- - -Add support for Django 2.1. - - -v1.5.2 --- 2017-10-18 ---------------------- - -Validates support for Django version 2.0b1. Improves discovery of -template files. - - -v1.5.1a --- 2017-04-05 ----------------------- - -Validates support for Django version 1.11. Testing for new package -maintainer Pamela McA'Nulty - - -v1.5.0 --- 2017-02-23 ---------------------- - -Removes support for Django versions below 1.8. Validates support for -Django version 1.11b1 - - -v1.4.2 --- 2017-02-06 ---------------------- - -Fixes another instance of `issue 32`_, which was the result of an -initialization order problem. - - - -v1.4.1 --- 2017-01-25 ---------------------- - -Fixes `issue 32`_, which was the result of an initialization order -problem. - -.. _issue 32: https://github.com/nedbat/django_coverage_plugin/issues/32 - - - -v1.4 --- 2017-01-16 -------------------- - -Django 1.10.5 is now supported. - -Checking settings configuration is deferred so that settings.py is -included in coverage reporting. Fixes `issue 28`_. - -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 - - - -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 - - - -v1.3 --- 2016-04-03 -------------------- - -Multiple template engines are allowed. Thanks, Simon Charette. - - - -v1.2.2 --- 2016-02-01 ---------------------- - -No change in code, but Django 1.9.2 is now supported. - - - -v1.2.1 --- 2016-01-28 ---------------------- - -The template debug settings are checked properly for people still using -``TEMPLATE_DEBUG`` in newer versions of Django. - - - -v1.2 --- 2016-01-16 -------------------- - -Check if template debugging is enabled in the settings, and raise a -visible warning if not. This prevents mysterious failures of the -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 - - - -v1.1 --- 2015-11-12 -------------------- - -Explicitly configure settings if need be to get things to work. - - - -v1.0 --- 2015-09-20 -------------------- - -First version :) diff --git a/MANIFEST.in b/MANIFEST.in index 7be7bf2..74dd042 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,7 +9,6 @@ exclude requirements.txt exclude tox.ini exclude .editorconfig include AUTHORS.txt -include HISTORY.rst include LICENSE.txt include NOTICE.txt include README.rst diff --git a/README.rst b/README.rst index e1d5b62..c9ad724 100644 --- a/README.rst +++ b/README.rst @@ -117,5 +117,163 @@ To run the tests:: $ pip install -r requirements.txt $ tox + +History +~~~~~~~ + +Unreleased +---------- + +Drop support for Python 3.4 and 3.5. + +A setting is available: ``template_extensions`` lets you set the file +extensions that will be considered when looking for unused templates +(requested in `issue 60`_). + +Fix an issue on Windows where file names were being compared +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 + +v1.8.0 --- 2020-01-23 +--------------------- + +Add support for: + +- Coverage 5 + +v1.7.0 --- 2020-01-16 +--------------------- + +Add support for: + +- Python 3.7 & 3.8 +- Django 2.2 & 3.0 + +v1.6.0 --- 2018-09-04 +--------------------- + +Add support for Django 2.1. + + +v1.5.2 --- 2017-10-18 +--------------------- + +Validates support for Django version 2.0b1. Improves discovery of +template files. + + +v1.5.1a --- 2017-04-05 +---------------------- + +Validates support for Django version 1.11. Testing for new package +maintainer Pamela McA'Nulty + + +v1.5.0 --- 2017-02-23 +--------------------- + +Removes support for Django versions below 1.8. Validates support for +Django version 1.11b1 + + +v1.4.2 --- 2017-02-06 +--------------------- + +Fixes another instance of `issue 32`_, which was the result of an +initialization order problem. + + + +v1.4.1 --- 2017-01-25 +--------------------- + +Fixes `issue 32`_, which was the result of an initialization order +problem. + +.. _issue 32: https://github.com/nedbat/django_coverage_plugin/issues/32 + + + +v1.4 --- 2017-01-16 +------------------- + +Django 1.10.5 is now supported. + +Checking settings configuration is deferred so that settings.py is +included in coverage reporting. Fixes `issue 28`_. + +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 + + + +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 + + + +v1.3 --- 2016-04-03 +------------------- + +Multiple template engines are allowed. Thanks, Simon Charette. + + + +v1.2.2 --- 2016-02-01 +--------------------- + +No change in code, but Django 1.9.2 is now supported. + + + +v1.2.1 --- 2016-01-28 +--------------------- + +The template debug settings are checked properly for people still using +``TEMPLATE_DEBUG`` in newer versions of Django. + + + +v1.2 --- 2016-01-16 +------------------- + +Check if template debugging is enabled in the settings, and raise a +visible warning if not. This prevents mysterious failures of the +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 + + + +v1.1 --- 2015-11-12 +------------------- + +Explicitly configure settings if need be to get things to work. + + + +v1.0 --- 2015-09-20 +------------------- + +First version :) + .. _coverage.py: http://nedbatchelder.com/code/coverage .. _dtcov: https://github.com/traff/dtcov diff --git a/howto.txt b/howto.txt index d29a877..0f474e7 100644 --- a/howto.txt +++ b/howto.txt @@ -8,7 +8,6 @@ Development Status :: 5 - Production/Stable - Copyright date in NOTICE.txt - Update README.rst with latest changes -- Update HISTORY.rst with latest changes - Kits: $ make kit $ make kit_upload From 3adc6ae2d766e75bac8f5d56484c817f9324e742 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 19:14:44 -0400 Subject: [PATCH 25/90] build: kit building targets --- Makefile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 159cc4f..29114a0 100644 --- a/Makefile +++ b/Makefile @@ -24,10 +24,9 @@ clean: ## Remove non-source files. sterile: clean ## Remove all non-controlled content, even if expensive. -rm -rf .tox* -SDIST_CMD = python setup.py sdist --formats=gztar -kit: - $(SDIST_CMD) +kit: ## Make the source distribution. + python setup.py sdist --formats=gztar -kit_upload: - twine upload dist/* +kit_upload: ## Upload the built distributions to PyPI. + twine upload --verbose dist/* From ea8c88b52011c3470815a3b0b4df568a862e4a6d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jun 2021 19:12:01 -0400 Subject: [PATCH 26/90] build: release v2.0.0 --- README.rst | 4 ++-- setup.py | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index c9ad724..9b09ea7 100644 --- a/README.rst +++ b/README.rst @@ -121,8 +121,8 @@ To run the tests:: History ~~~~~~~ -Unreleased ----------- +v2.0.0 --- 2021-06-08 +--------------------- Drop support for Python 3.4 and 3.5. diff --git a/setup.py b/setup.py index da09266..e10d385 100644 --- a/setup.py +++ b/setup.py @@ -33,11 +33,10 @@ def read(*names, **kwargs): License :: OSI Approved :: Apache Software License Operating System :: OS Independent Programming Language :: Python :: 2.7 -Programming Language :: Python :: 3.4 -Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 +Programming Language :: Python :: 3.9 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Quality Assurance @@ -46,15 +45,13 @@ def read(*names, **kwargs): Framework :: Django Framework :: Django :: 1.8 Framework :: Django :: 1.11 -Framework :: Django :: 2.0 -Framework :: Django :: 2.1 Framework :: Django :: 2.2 -Framework :: Django :: 3.0 +Framework :: Django :: 3.2 """ setup( name='django_coverage_plugin', - version='1.8.0', + version='2.0.0', description='Django template coverage.py plugin', long_description=( re.compile( From 8fe45346d334100d4063af7bb074cd2f351f84c3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 9 Jun 2021 05:35:04 -0400 Subject: [PATCH 27/90] build: people like GitHub releases --- howto.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/howto.txt b/howto.txt index 0f474e7..1144193 100644 --- a/howto.txt +++ b/howto.txt @@ -12,3 +12,4 @@ $ make kit $ make kit_upload - tag git +- make a new gh release: https://github.com/nedbat/django_coverage_plugin/releases/new From 4ab844c5076d3ea7b7881198b4412090fe70c4b4 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 3 Oct 2021 07:50:13 -0400 Subject: [PATCH 28/90] test: be flexible about how HTML files are named Coverage.py 6.0 changed the way the HTML files are named. Now it could be either: - old: htmlcov/templates_test_simple_html.html - new: htmlcov/d_9ed9d281467a41a1_test_simple_html.html --- tests/test_html.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_html.py b/tests/test_html.py index 56099b1..c22ac00 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -4,6 +4,8 @@ """Tests of HTML reporting for django_coverage_plugin.""" +import glob + from .plugin_test import DjangoPluginTestCase @@ -16,6 +18,7 @@ def test_simple(self): self.run_django_coverage() self.cov.html_report() - with open("htmlcov/templates_test_simple_html.html") as fhtml: + html_file = glob.glob("htmlcov/*_test_simple_html.html")[0] + with open(html_file) as fhtml: html = fhtml.read() self.assertIn('Simple © 2015', html) From c4ec0691906dc0923c494efc9c9236d3aa21be73 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 3 Oct 2021 09:00:37 -0400 Subject: [PATCH 29/90] test: adapt to coverage.py 6.0 changes Coverage.py 6.0 issues true Python warnings instead of just printing to stderr, so the tests have to adapt based on the coverage version. --- tests/plugin_test.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/plugin_test.py b/tests/plugin_test.py index dc171b7..5e035ed 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -231,19 +231,27 @@ def assert_plugin_disabled(self, msg): """Assert that our plugin was disabled during an operation.""" # self.run_django_coverage will raise PluginDisabled if the plugin # was disabled. - with self.assertRaises(PluginDisabled): - yield - stderr = self.stderr() + # Coverage.py 6.0 made the warnings real warnings, so we have to adapt + # how we test the warnings based on the version. + if coverage.version.version_info >= (6, 0): + import coverage.exceptions as cov_exc + ctxmgr = self.assertWarns(cov_exc.CoverageWarning) + else: + ctxmgr = nullcontext() + with ctxmgr as cw: + with self.assertRaises(PluginDisabled): + yield + + if cw is not None: + warn_text = "\n".join(str(w.message) for w in cw.warnings) + else: + warn_text = self.stderr() self.assertIn( - "Coverage.py warning: " "Disabling plug-in 'django_coverage_plugin.DjangoTemplatePlugin' " "due to an exception:", - stderr - ) - self.assertIn( - "DjangoTemplatePluginException: " + msg, - stderr + warn_text ) + self.assertIn("DjangoTemplatePluginException: " + msg, warn_text) def squashed(s): @@ -282,3 +290,9 @@ def test_thing(self): class PluginDisabled(Exception): """Raised if we find that our plugin has been disabled.""" pass + + +@contextlib.contextmanager +def nullcontext(): + """For when we need a context manager to do nothing.""" + yield None From f0b98e4029838bc7ef4e6177e00df4667c654f97 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 6 Oct 2021 13:48:20 -0500 Subject: [PATCH 30/90] add 3.10 to job matrix --- .github/workflows/tests.yml | 1 + tox.ini | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 367ad44..9e2cf1e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,6 +36,7 @@ jobs: - "3.7" - "3.8" - "3.9" + - "3.10" exclude: # Windows 2.7 doesn't work because Microsoft removed stuff we needed. - os: windows-latest diff --git a/tox.ini b/tox.ini index 3cfcf1e..aa1a2dc 100644 --- a/tox.ini +++ b/tox.ini @@ -19,6 +19,7 @@ envlist = py37-django{22,32}, py38-django{22,32,tip}, py39-django{22,32,tip}, + py310-django{32,tip}, check,pkgcheck,doc [testenv] @@ -75,3 +76,4 @@ python = 3.7: py37 3.8: py38 3.9: py39 + 3.10: py310 From 33d5d409af88a6ac6e64b96116c8f5a47b160186 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 6 Oct 2021 13:54:53 -0500 Subject: [PATCH 31/90] update trove classifiers --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index e10d385..39645e6 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ def read(*names, **kwargs): Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 +Programming Language :: Python :: 3.10 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Quality Assurance From 5d499a6979f5f920c15aec66c517856054aed545 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 6 Oct 2021 15:23:33 -0400 Subject: [PATCH 32/90] build: release v2.0.1 --- NOTICE.txt | 2 +- README.rst | 7 ++++++- setup.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 03e0879..df68d64 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,4 +1,4 @@ -Copyright 2015-2020 Ned Batchelder. All rights reserved. +Copyright 2015-2021 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 diff --git a/README.rst b/README.rst index 9b09ea7..49272c2 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ Django Template Coverage.py Plugin A `coverage.py`_ plugin to measure test coverage of Django templates. -Supported Python versions: 2.7, 3.6, 3.7, 3.8 and 3.9. +Supported Python versions: 2.7, and 3.6 through 3.10. Supported Django versions: 1.8, 1.11, 2.x and 3.x. @@ -121,6 +121,11 @@ To run the tests:: History ~~~~~~~ +v2.0.1 --- 2021-10-06 +--------------------- + +Test and claim our support on Python 3.10. + v2.0.0 --- 2021-06-08 --------------------- diff --git a/setup.py b/setup.py index 39645e6..8380d7c 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ def read(*names, **kwargs): setup( name='django_coverage_plugin', - version='2.0.0', + version='2.0.1', description='Django template coverage.py plugin', long_description=( re.compile( From 7b1628b4d3f4c34691a73f3dcb0169493d0a9af9 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 4 Nov 2021 14:33:42 +0100 Subject: [PATCH 33/90] Add pyproject.toml configuration example Closes #77 --- README.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 49272c2..b363428 100644 --- a/README.rst +++ b/README.rst @@ -72,12 +72,12 @@ Configuration ~~~~~~~~~~~~~ The Django template plugin uses some existing settings from your -.coveragerc file. The ``source=``, ``include=``, and ``omit=`` options +``.coveragerc`` file. The ``source=``, ``include=``, and ``omit=`` options control what template files are included in the report. The plugin can find unused template and include them in your results. By default, it will look for files in your templates directory with an extension -of .html, .htm, or .txt. You can configure it to look for a different set of +of ``.html``, ``.htm``, or ``.txt``. You can configure it to look for a different set of extensions if you like:: [run] @@ -86,6 +86,15 @@ extensions if you like:: [django_coverage_plugin] template_extensions = html, txt, tex, email +If you use ``pyproject.toml`` for tool configuration use:: + + [tool.coverage.run] + plugins = [ + 'django_coverage_plugin', + ] + + [tool.coverage.django_coverage_plugin] + template_extensions = 'html, txt, tex, email' Caveats ~~~~~~~ From 8a43a8dd23bd2c2ad77f3115c70f9198db75465b Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 4 Nov 2021 15:07:43 +0100 Subject: [PATCH 34/90] fix: raise a Coverage-handlable exception if a file can't be read. #78 --- README.rst | 11 +++++ django_coverage_plugin/plugin.py | 10 ++++- tests/test_source.py | 70 ++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index b363428..0057273 100644 --- a/README.rst +++ b/README.rst @@ -130,6 +130,17 @@ To run the tests:: History ~~~~~~~ +Unreleased +---------- + +If a non-UTF8 file was found when looking for templates, it would fail when +reading during the reporting phase, ending execution. This failure is now +raised in a way that can be ignored with a .coveragerc setting of ``[report] +ignore_errors=True`` (`issue 78`_). + +.. _issue 78: https://github.com/nedbat/django_coverage_plugin/issues/78 + + v2.0.1 --- 2021-10-06 --------------------- diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index a3e4867..a60273d 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -8,6 +8,11 @@ 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 @@ -303,7 +308,10 @@ def __init__(self, filename): def source(self): if self._source is None: - self._source = read_template_source(self.filename) + try: + self._source = read_template_source(self.filename) + except (IOError, UnicodeError) as exc: + raise NoSource("Couldn't read {}: {}".format(self.filename, exc)) return self._source def lines(self): diff --git a/tests/test_source.py b/tests/test_source.py index 76992d3..a4ab11b 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -3,6 +3,14 @@ """Tests of template inheritance for django_coverage_plugin.""" +import os + +try: + from coverage.exceptions import NoSource +except ImportError: + # for coverage 5.x + from coverage.misc import NoSource + from .plugin_test import DjangoPluginTestCase @@ -64,3 +72,65 @@ def test_customized_extensions(self): self.assert_analysis([1], name="phd.tex", missing=[1]) # The editor leave-behinds are not in the measured files. self.assert_measured_files("main.html", "unused.html", "phd.tex") + + def test_non_utf8_error(self): + # A non-UTF8 text file will raise an error. + self.make_file(".coveragerc", """\ + [run] + plugins = django_coverage_plugin + source = . + """) + # This is a template that is rendered. + self.make_template(name="main.html", text="Hello") + # Extra file containing a word encoded in CP-1252 + self.make_file(self._path("static/changelog.txt"), bytes=b"sh\xf6n") + + text = self.run_django_coverage(name="main.html") + self.assertEqual(text, "Hello") + + self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) + self.assert_analysis([1], name="main.html") + with self.assertRaisesRegexp(NoSource, r"changelog.txt.*invalid start byte"): + self.cov.html_report() + + def test_non_utf8_omitted(self): + # If we omit the directory with the non-UTF8 file, all is well. + self.make_file(".coveragerc", """\ + [run] + plugins = django_coverage_plugin + source = . + [report] + omit = */static/* + """) + # This is a template that is rendered. + self.make_template(name="main.html", text="Hello") + # Extra file containing a word encoded in CP-1252 + self.make_file(self._path("static/changelog.txt"), bytes=b"sh\xf6n") + + text = self.run_django_coverage(name="main.html") + self.assertEqual(text, "Hello") + + self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) + self.assert_analysis([1], name="main.html") + self.cov.html_report() + + def test_non_utf8_ignored(self): + # If we ignore reporting errors, a non-UTF8 text file is fine. + self.make_file(".coveragerc", """\ + [run] + plugins = django_coverage_plugin + source = . + [report] + ignore_errors = True + """) + # This is a template that is rendered. + self.make_template(name="main.html", text="Hello") + # Extra file containing a word encoded in CP-1252 + self.make_file(self._path("static/changelog.txt"), bytes=b"sh\xf6n") + + text = self.run_django_coverage(name="main.html") + self.assertEqual(text, "Hello") + + self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) + self.assert_analysis([1], name="main.html") + self.cov.html_report() From e7a4ba4b9da89c9bd09fedf72ab57540342490bd Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 11 Nov 2021 08:48:05 -0500 Subject: [PATCH 35/90] fix: don't find HTML report as templates --- README.rst | 3 +++ django_coverage_plugin/__init__.py | 4 +++- django_coverage_plugin/plugin.py | 6 +++++ tests/test_source.py | 38 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 0057273..3df7f0c 100644 --- a/README.rst +++ b/README.rst @@ -138,6 +138,9 @@ reading during the reporting phase, ending execution. This failure is now raised in a way that can be ignored with a .coveragerc setting of ``[report] 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 diff --git a/django_coverage_plugin/__init__.py b/django_coverage_plugin/__init__.py index e51c14e..bac9149 100644 --- a/django_coverage_plugin/__init__.py +++ b/django_coverage_plugin/__init__.py @@ -8,4 +8,6 @@ def coverage_init(reg, options): - reg.add_file_tracer(DjangoTemplatePlugin(options)) + plugin = DjangoTemplatePlugin(options) + reg.add_file_tracer(plugin) + reg.add_configurer(plugin) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index a60273d..41a091c 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -184,6 +184,9 @@ def sys_info(self): )), ] + def configure(self, config): + self.html_report_dir = os.path.abspath(config.get_option("html:directory")) + def file_tracer(self, filename): if os.path.normcase(filename).startswith(self.django_template_dir): if not self.debug_checked: @@ -204,6 +207,9 @@ def find_executable_files(self, src_dir): rx = r"^[^.#~!$@%^&*()+=,]+\.(" + "|".join(self.extensions) + r")$" for (dirpath, dirnames, filenames) in os.walk(src_dir): + if dirpath == self.html_report_dir: + # Don't confuse the HTML report with HTML templates. + continue for filename in filenames: if re.search(rx, filename): yield os.path.join(dirpath, filename) diff --git a/tests/test_source.py b/tests/test_source.py index a4ab11b..80b53d4 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -134,3 +134,41 @@ def test_non_utf8_ignored(self): self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) self.assert_analysis([1], name="main.html") self.cov.html_report() + + def test_htmlcov_isnt_measured(self): + # We used to find the HTML report and think it was template files. + self.make_file(".coveragerc", """\ + [run] + plugins = django_coverage_plugin + source = . + """) + self.make_template(name="main.html", text="Hello") + text = self.run_django_coverage(name="main.html") + self.assertEqual(text, "Hello") + + self.assert_measured_files("main.html") + self.cov.html_report() + + # Run coverage again with an HTML report on disk. + text = self.run_django_coverage(name="main.html") + self.assert_measured_files("main.html") + + def test_custom_html_report_isnt_measured(self): + # We used to find the HTML report and think it was template files. + self.make_file(".coveragerc", """\ + [run] + plugins = django_coverage_plugin + source = . + [html] + directory = my_html_report + """) + self.make_template(name="main.html", text="Hello") + text = self.run_django_coverage(name="main.html") + self.assertEqual(text, "Hello") + + self.assert_measured_files("main.html") + self.cov.html_report() + + # Run coverage again with an HTML report on disk. + text = self.run_django_coverage(name="main.html") + self.assert_measured_files("main.html") From 9ba2de042cc5e04ddf1929f38ca3293e2b5e8e13 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 11 Nov 2021 08:57:40 -0500 Subject: [PATCH 36/90] build: use build --- Makefile | 3 ++- howto.txt | 2 +- requirements.txt | 1 + tox.ini | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 29114a0..9ee8cb0 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,8 @@ sterile: clean ## Remove all non-controlled content, ev kit: ## Make the source distribution. - python setup.py sdist --formats=gztar + python -m build + python -m twine check dist/* kit_upload: ## Upload the built distributions to PyPI. twine upload --verbose dist/* diff --git a/howto.txt b/howto.txt index 1144193..fca9910 100644 --- a/howto.txt +++ b/howto.txt @@ -9,7 +9,7 @@ - Copyright date in NOTICE.txt - Update README.rst with latest changes - Kits: - $ make kit + $ make clean kit $ make kit_upload - tag git - make a new gh release: https://github.com/nedbat/django_coverage_plugin/releases/new diff --git a/requirements.txt b/requirements.txt index 1b68e9e..43e1737 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ # To run tests, we just need tox. tox >= 1.8 +build twine diff --git a/tox.ini b/tox.ini index aa1a2dc..68b6440 100644 --- a/tox.ini +++ b/tox.ini @@ -52,13 +52,14 @@ commands = [testenv:pkgcheck] skip_install = true deps = + build docutils check-manifest readme-renderer twine commands = - python setup.py -q sdist + python -m build --config-setting=--quiet twine check dist/* check-manifest {toxinidir} From 06b758ed4fe7401ebf6a025f2223ac65297ef5ca Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 11 Nov 2021 09:02:40 -0500 Subject: [PATCH 37/90] docs: use em-dashes that GitHub will render --- README.rst | 72 +++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/README.rst b/README.rst index 3df7f0c..fd1564a 100644 --- a/README.rst +++ b/README.rst @@ -144,13 +144,13 @@ found and believed to be unmeasured HTML template files. This is now fixed. .. _issue 78: https://github.com/nedbat/django_coverage_plugin/issues/78 -v2.0.1 --- 2021-10-06 ---------------------- +v2.0.1 — 2021-10-06 +------------------- Test and claim our support on Python 3.10. -v2.0.0 --- 2021-06-08 ---------------------- +v2.0.0 — 2021-06-08 +------------------- Drop support for Python 3.4 and 3.5. @@ -168,58 +168,58 @@ during test collection. Thanks to Daniel Izquierdo for the fix. .. _issue 60: https://github.com/nedbat/django_coverage_plugin/issues/60 .. _issue 63: https://github.com/nedbat/django_coverage_plugin/issues/63 -v1.8.0 --- 2020-01-23 ---------------------- +v1.8.0 — 2020-01-23 +------------------- Add support for: - Coverage 5 -v1.7.0 --- 2020-01-16 ---------------------- +v1.7.0 — 2020-01-16 +------------------- Add support for: - Python 3.7 & 3.8 - Django 2.2 & 3.0 -v1.6.0 --- 2018-09-04 ---------------------- +v1.6.0 — 2018-09-04 +------------------- Add support for Django 2.1. -v1.5.2 --- 2017-10-18 ---------------------- +v1.5.2 — 2017-10-18 +------------------- Validates support for Django version 2.0b1. Improves discovery of template files. -v1.5.1a --- 2017-04-05 ----------------------- +v1.5.1a — 2017-04-05 +-------------------- Validates support for Django version 1.11. Testing for new package maintainer Pamela McA'Nulty -v1.5.0 --- 2017-02-23 ---------------------- +v1.5.0 — 2017-02-23 +------------------- Removes support for Django versions below 1.8. Validates support for Django version 1.11b1 -v1.4.2 --- 2017-02-06 ---------------------- +v1.4.2 — 2017-02-06 +------------------- Fixes another instance of `issue 32`_, which was the result of an initialization order problem. -v1.4.1 --- 2017-01-25 ---------------------- +v1.4.1 — 2017-01-25 +------------------- Fixes `issue 32`_, which was the result of an initialization order problem. @@ -228,8 +228,8 @@ problem. -v1.4 --- 2017-01-16 -------------------- +v1.4 — 2017-01-16 +----------------- Django 1.10.5 is now supported. @@ -245,8 +245,8 @@ engine is supported, and it must be configured with -v1.3.1 --- 2016-06-02 ---------------------- +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`_. @@ -255,30 +255,30 @@ programs that don't need settings. Fixes `issue 18`_. -v1.3 --- 2016-04-03 -------------------- +v1.3 — 2016-04-03 +----------------- Multiple template engines are allowed. Thanks, Simon Charette. -v1.2.2 --- 2016-02-01 ---------------------- +v1.2.2 — 2016-02-01 +------------------- No change in code, but Django 1.9.2 is now supported. -v1.2.1 --- 2016-01-28 ---------------------- +v1.2.1 — 2016-01-28 +------------------- The template debug settings are checked properly for people still using ``TEMPLATE_DEBUG`` in newer versions of Django. -v1.2 --- 2016-01-16 -------------------- +v1.2 — 2016-01-16 +----------------- Check if template debugging is enabled in the settings, and raise a visible warning if not. This prevents mysterious failures of the @@ -291,15 +291,15 @@ been applied yet. -v1.1 --- 2015-11-12 -------------------- +v1.1 — 2015-11-12 +----------------- Explicitly configure settings if need be to get things to work. -v1.0 --- 2015-09-20 -------------------- +v1.0 — 2015-09-20 +----------------- First version :) From 597f07d60fffe05b9062b6c41afa722a4b32f3ba Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 11 Nov 2021 09:03:43 -0500 Subject: [PATCH 38/90] build: release v2.0.2 --- README.rst | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index fd1564a..8b1a563 100644 --- a/README.rst +++ b/README.rst @@ -130,8 +130,8 @@ To run the tests:: History ~~~~~~~ -Unreleased ----------- +v2.0.2 — 2021-11-11 +------------------- If a non-UTF8 file was found when looking for templates, it would fail when reading during the reporting phase, ending execution. This failure is now diff --git a/setup.py b/setup.py index 8380d7c..a7f14a1 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ def read(*names, **kwargs): setup( name='django_coverage_plugin', - version='2.0.1', + version='2.0.2', description='Django template coverage.py plugin', long_description=( re.compile( From 70fae430638a6b65d143a3d2e4f870f8ff5efe5d Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 1 May 2022 16:06:52 +0100 Subject: [PATCH 39/90] fix: add support for Django 4.0 --- README.rst | 7 ++++++- setup.py | 1 + tox.ini | 7 ++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 8b1a563..2936583 100644 --- a/README.rst +++ b/README.rst @@ -28,7 +28,7 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. Supported Python versions: 2.7, and 3.6 through 3.10. -Supported Django versions: 1.8, 1.11, 2.x and 3.x. +Supported Django versions: 1.8, 1.11, 2.x, 3.x and 4.x. Supported coverage.py versions: 4.x or higher. @@ -130,6 +130,11 @@ To run the tests:: History ~~~~~~~ +Unreleased +---------- + +Add support for Django 4.0 + v2.0.2 — 2021-11-11 ------------------- diff --git a/setup.py b/setup.py index a7f14a1..18ec43b 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ def read(*names, **kwargs): Framework :: Django :: 1.11 Framework :: Django :: 2.2 Framework :: Django :: 3.2 +Framework :: Django :: 4.0 """ setup( diff --git a/tox.ini b/tox.ini index 68b6440..50f9df3 100644 --- a/tox.ini +++ b/tox.ini @@ -17,9 +17,9 @@ envlist = py27-django{18,111}, py36-django{18,111,22,32}, py37-django{22,32}, - py38-django{22,32,tip}, - py39-django{22,32,tip}, - py310-django{32,tip}, + py38-django{22,32,40,tip}, + py39-django{22,32,40,tip}, + py310-django{32,40,tip}, check,pkgcheck,doc [testenv] @@ -30,6 +30,7 @@ deps = django111: Django>=1.11,<2.0 django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 + django40: Django>=4.0,<4.1 djangotip: https://github.com/django/django/archive/main.tar.gz commands = From edb0b7770ccbaaa2b61968bdf8a89c93db3e2236 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 3 May 2022 21:42:51 +0100 Subject: [PATCH 40/90] test: fix build against djangotip Django recently enabled the cached template loader by default in development. This was added in: https://github.com/django/django/commit/bf7c51a5f4da5f00b46923545ea6657ba9556bf6 As a result, some tests started failing when the whole test suite was run, but not when they were run individually. We can fix this by setting the template loaders in our test settings. --- django_coverage_plugin/plugin.py | 2 +- tests/plugin_test.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 41a091c..72b48e6 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -365,7 +365,7 @@ def lines(self): continue if extends and not inblock: - # In an inheriting tempalte, ignore all tags outside of + # In an inheriting template, ignore all tags outside of # blocks. continue diff --git a/tests/plugin_test.py b/tests/plugin_test.py index 5e035ed..1798971 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -45,6 +45,9 @@ def test_settings(): 'DIRS': ['templates'], # where the tests put things. 'OPTIONS': { 'debug': True, + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + ] }, }, ], From fa583d5c38401d8ac315b11b6b72690d4e0436ad Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 4 May 2022 06:26:34 -0400 Subject: [PATCH 41/90] build: release v2.0.3 --- NOTICE.txt | 2 +- README.rst | 5 +++-- setup.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index df68d64..69e5a4f 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,4 +1,4 @@ -Copyright 2015-2021 Ned Batchelder. All rights reserved. +Copyright 2015-2022 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 diff --git a/README.rst b/README.rst index 2936583..caf761a 100644 --- a/README.rst +++ b/README.rst @@ -130,11 +130,12 @@ To run the tests:: History ~~~~~~~ -Unreleased ----------- +v2.0.3 — 2022-05-04 +------------------- Add support for Django 4.0 + v2.0.2 — 2021-11-11 ------------------- diff --git a/setup.py b/setup.py index 18ec43b..d5fb17b 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def read(*names, **kwargs): setup( name='django_coverage_plugin', - version='2.0.2', + version='2.0.3', description='Django template coverage.py plugin', long_description=( re.compile( From 2e95412595fa5d1017fa38ea86acd29ef0735fe1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 4 May 2022 06:35:32 -0400 Subject: [PATCH 42/90] build: slightly more modern release processes --- Makefile | 6 +++++- howto.txt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9ee8cb0..2113b40 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,8 @@ kit: ## Make the source distribution. python -m twine check dist/* kit_upload: ## Upload the built distributions to PyPI. - twine upload --verbose dist/* + python -m twine upload --verbose dist/* + +tag: ## Make a git tag with the version number + git tag -a -m "Version v$$(python setup.py --version)" v$$(python setup.py --version) + git push --all diff --git a/howto.txt b/howto.txt index fca9910..4481256 100644 --- a/howto.txt +++ b/howto.txt @@ -11,5 +11,5 @@ - Kits: $ make clean kit $ make kit_upload -- tag git + $ make tag - make a new gh release: https://github.com/nedbat/django_coverage_plugin/releases/new From 54691335d8039c46b3c7066c8674168b0f24bdac Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 18 Jun 2022 11:23:02 -0400 Subject: [PATCH 43/90] build: just enough to get `scriv github-release` to work --- README.rst | 2 ++ requirements.txt | 1 + setup.cfg | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/README.rst b/README.rst index caf761a..e7c7541 100644 --- a/README.rst +++ b/README.rst @@ -130,6 +130,8 @@ To run the tests:: History ~~~~~~~ +.. scriv-insert-here + v2.0.3 — 2022-05-04 ------------------- diff --git a/requirements.txt b/requirements.txt index 43e1737..fbf51ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ # To run tests, we just need tox. tox >= 1.8 build +scriv twine diff --git a/setup.cfg b/setup.cfg index 679b318..91522f4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,3 +8,8 @@ filterwarnings = 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 = -. From a7b38513a0227594ffe5f845db74c4521fb06dc8 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 31 Oct 2022 04:57:21 -0500 Subject: [PATCH 44/90] Add Python 3.11 to CI, tox, and trove classifiers (#90) * add python 3.11 to CI, tox, and trove classifiers * python 3.11 only officially supported by Django 4.1+ --- .github/workflows/tests.yml | 1 + setup.py | 1 + tox.ini | 2 ++ 3 files changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9e2cf1e..04f3058 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,6 +37,7 @@ jobs: - "3.8" - "3.9" - "3.10" + - "3.11" exclude: # Windows 2.7 doesn't work because Microsoft removed stuff we needed. - os: windows-latest diff --git a/setup.py b/setup.py index d5fb17b..2f9f548 100644 --- a/setup.py +++ b/setup.py @@ -38,6 +38,7 @@ def read(*names, **kwargs): Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 +Programming Language :: Python :: 3.11 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Quality Assurance diff --git a/tox.ini b/tox.ini index 50f9df3..f685e90 100644 --- a/tox.ini +++ b/tox.ini @@ -20,6 +20,7 @@ envlist = py38-django{22,32,40,tip}, py39-django{22,32,40,tip}, py310-django{32,40,tip}, + py311-django{tip}, check,pkgcheck,doc [testenv] @@ -79,3 +80,4 @@ python = 3.8: py38 3.9: py39 3.10: py310 + 3.11: py311 From 1bf107c97bb7c96f95557fe670b5aeecc020d9ae Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 31 Oct 2022 05:27:57 -0500 Subject: [PATCH 45/90] add django 4.1 to tox envs (#91) Co-authored-by: Ned Batchelder --- tox.ini | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index f685e90..63368b1 100644 --- a/tox.ini +++ b/tox.ini @@ -17,9 +17,9 @@ envlist = py27-django{18,111}, py36-django{18,111,22,32}, py37-django{22,32}, - py38-django{22,32,40,tip}, - py39-django{22,32,40,tip}, - py310-django{32,40,tip}, + py38-django{22,32,40,41,tip}, + py39-django{22,32,40,41,tip}, + py310-django{32,40,41,tip}, py311-django{tip}, check,pkgcheck,doc @@ -32,6 +32,7 @@ deps = django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 django40: Django>=4.0,<4.1 + django41: Django>=4.1,<4.2 djangotip: https://github.com/django/django/archive/main.tar.gz commands = From 5330a9489d6bebf2910f1c26ab19b37bbabbbfe7 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 31 Oct 2022 06:37:32 -0400 Subject: [PATCH 46/90] docs: updates to the readme --- README.rst | 25 +++++++++++++++---------- setup.py | 13 +++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/README.rst b/README.rst index e7c7541..e96fa9e 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,13 @@ +================================== +Django Template Coverage.py Plugin +================================== + +A `coverage.py`_ plugin to measure test coverage of Django templates. + .. start-badges -|status| |kit| |license| |versions| |djversions| +| |status| |kit| |license| +| |versions| |djversions| .. |status| image:: https://img.shields.io/pypi/status/django_coverage_plugin.svg :target: https://pypi.python.org/pypi/django_coverage_plugin @@ -14,23 +21,21 @@ .. |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.0%20%7C%202.1%20%7C%202.2%20%7C%203.0-44b78b.svg +.. |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 :target: https://pypi.python.org/pypi/django_coverage_plugin :alt: Supported Django Versions -.. end-badges +------------------ -================================== -Django Template Coverage.py Plugin -================================== +.. end-badges -A `coverage.py`_ plugin to measure test coverage of Django templates. +Supported on: -Supported Python versions: 2.7, and 3.6 through 3.10. +- Python: 2.7, and 3.6 through 3.11. -Supported Django versions: 1.8, 1.11, 2.x, 3.x and 4.x. +- Django: 1.8, 1.11, 2.x, 3.x and 4.x. -Supported coverage.py versions: 4.x or higher. +- Coverage.py: 4.x or higher. The plugin is pip installable:: diff --git a/setup.py b/setup.py index 2f9f548..e4cea78 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ def read(*names, **kwargs): Framework :: Django :: 1.11 Framework :: Django :: 2.2 Framework :: Django :: 3.2 -Framework :: Django :: 4.0 +Framework :: Django :: 4.1 """ setup( @@ -57,10 +57,11 @@ def read(*names, **kwargs): version='2.0.3', description='Django template coverage.py plugin', long_description=( - re.compile( - '^.. start-badges.*^.. end-badges', - re.M | re.S, - ).sub('', read('README.rst')) + re.sub( + '(?ms)^.. start-badges.*^.. end-badges', + '', + read('README.rst'), + ) ), long_description_content_type='text/x-rst', author='Ned Batchelder', @@ -71,6 +72,6 @@ def read(*names, **kwargs): 'coverage', 'six >= 1.4.0', ], - license='Apache 2.0', + license='Apache-2.0', classifiers=classifiers.splitlines(), ) From 1a3cbf795778d97c9a3e2eba52126351520a44bc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 31 Oct 2022 06:57:50 -0400 Subject: [PATCH 47/90] build: release v2.0.4 --- Makefile | 6 ++++-- README.rst | 7 ++++++- howto.txt | 2 +- setup.py | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2113b40..39992d8 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,6 @@ clean: ## Remove non-source files. sterile: clean ## Remove all non-controlled content, even if expensive. -rm -rf .tox* - kit: ## Make the source distribution. python -m build python -m twine check dist/* @@ -32,6 +31,9 @@ kit: ## Make the source distribution. kit_upload: ## Upload the built distributions to PyPI. python -m twine upload --verbose dist/* -tag: ## Make a git tag with the version number +tag: ## Make a git tag with the version number. git tag -a -m "Version v$$(python setup.py --version)" v$$(python setup.py --version) git push --all + +ghrelease: ## Make a GitHub release for the latest version. + python -m scriv github-release diff --git a/README.rst b/README.rst index e96fa9e..9cb12c1 100644 --- a/README.rst +++ b/README.rst @@ -137,10 +137,15 @@ History .. scriv-insert-here +v2.0.4 — 2022-10-31 +------------------- + +Declare our support for Python 3.11 and Django 4.1. + v2.0.3 — 2022-05-04 ------------------- -Add support for Django 4.0 +Add support for Django 4.0. v2.0.2 — 2021-11-11 diff --git a/howto.txt b/howto.txt index 4481256..f3cdaa8 100644 --- a/howto.txt +++ b/howto.txt @@ -12,4 +12,4 @@ $ make clean kit $ make kit_upload $ make tag -- make a new gh release: https://github.com/nedbat/django_coverage_plugin/releases/new + $ make ghrelease diff --git a/setup.py b/setup.py index e4cea78..c2c7a8a 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ def read(*names, **kwargs): setup( name='django_coverage_plugin', - version='2.0.3', + version='2.0.4', description='Django template coverage.py plugin', long_description=( re.sub( From 003b6d055ad362a84480ef24ddc71e6e4350514f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 31 Oct 2022 07:03:29 -0400 Subject: [PATCH 48/90] docs: move a url so ghrelease will work --- README.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 9cb12c1..4d08b53 100644 --- a/README.rst +++ b/README.rst @@ -234,6 +234,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 v1.4.1 — 2017-01-25 @@ -242,9 +243,6 @@ v1.4.1 — 2017-01-25 Fixes `issue 32`_, which was the result of an initialization order problem. -.. _issue 32: https://github.com/nedbat/django_coverage_plugin/issues/32 - - v1.4 — 2017-01-16 ----------------- From 739306f6a129d148a81fb81b612dcb8807fcecec Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 4 Dec 2022 06:05:36 -0500 Subject: [PATCH 49/90] refactor: drop support for py<3.7 and django<1.11 --- .github/workflows/tests.yml | 8 +----- README.rst | 10 +++++-- django_coverage_plugin/plugin.py | 45 ++++++++++++-------------------- setup.py | 5 ---- tests/banner.py | 2 -- tests/plugin_test.py | 4 --- tests/test_extends.py | 42 +---------------------------- tox.ini | 9 ++----- 8 files changed, 28 insertions(+), 97 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 04f3058..14bf40d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,17 +31,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. - - "2.7" - - "3.6" - "3.7" - "3.8" - "3.9" - "3.10" - "3.11" - exclude: - # Windows 2.7 doesn't work because Microsoft removed stuff we needed. - - os: windows-latest - python-version: "2.7" fail-fast: false steps: @@ -85,7 +79,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v2" with: - python-version: "3.8" + python-version: "3.7" - name: "Install dependencies" run: | diff --git a/README.rst b/README.rst index 4d08b53..ce3a935 100644 --- a/README.rst +++ b/README.rst @@ -31,9 +31,9 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. Supported on: -- Python: 2.7, and 3.6 through 3.11. +- Python: 3.7 through 3.11. -- Django: 1.8, 1.11, 2.x, 3.x and 4.x. +- Django: 1.11, 2.x, 3.x and 4.x. - Coverage.py: 4.x or higher. @@ -137,6 +137,12 @@ History .. scriv-insert-here +Next +---- + +Dropped support for Python 2.7, Python 3.6, and Django 1.8. + + v2.0.4 — 2022-10-31 ------------------- diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 72b48e6..df07f2f 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -3,8 +3,6 @@ """The Django template coverage plugin.""" -from __future__ import print_function - import os.path import re @@ -99,39 +97,28 @@ def check_debug(): return True -if django.VERSION < (1, 8): - raise RuntimeError("Django Coverage Plugin requires Django 1.8 or higher") +if django.VERSION < (1, 11): + raise RuntimeError("Django Coverage Plugin requires Django 1.11 or higher") -if django.VERSION >= (1, 9): - # Since we are grabbing at internal details, we have to adapt as they - # change over versions. - def filename_for_frame(frame): - try: - return frame.f_locals["self"].origin.name - except (KeyError, AttributeError): - return None +# Since we are grabbing at internal details, we have to adapt as they +# change over versions. +def filename_for_frame(frame): + try: + return frame.f_locals["self"].origin.name + except (KeyError, AttributeError): + return None - def position_for_node(node): - try: - return node.token.position - except AttributeError: - return None - def position_for_token(token): - return token.position -else: - def filename_for_frame(frame): - try: - return frame.f_locals["self"].source[0].name - except (KeyError, AttributeError, IndexError): - return None +def position_for_node(node): + try: + return node.token.position + except AttributeError: + return None - def position_for_node(node): - return node.source[1] - def position_for_token(token): - return token.source[1] +def position_for_token(token): + return token.position def read_template_source(filename): diff --git a/setup.py b/setup.py index c2c7a8a..3e8ca40 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- encoding: utf-8 -*- """Setup for Django Coverage Plugin Licensed under the Apache 2.0 License @@ -7,7 +6,6 @@ - https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt """ -from __future__ import absolute_import, print_function import io import re @@ -32,8 +30,6 @@ def read(*names, **kwargs): Intended Audience :: Developers License :: OSI Approved :: Apache Software License Operating System :: OS Independent -Programming Language :: Python :: 2.7 -Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 @@ -45,7 +41,6 @@ def read(*names, **kwargs): Topic :: Software Development :: Testing Development Status :: 5 - Production/Stable Framework :: Django -Framework :: Django :: 1.8 Framework :: Django :: 1.11 Framework :: Django :: 2.2 Framework :: Django :: 3.2 diff --git a/tests/banner.py b/tests/banner.py index 2febc6e..9c2fb58 100644 --- a/tests/banner.py +++ b/tests/banner.py @@ -3,8 +3,6 @@ """For printing the versions from tox.ini.""" -from __future__ import print_function - import platform import django diff --git a/tests/plugin_test.py b/tests/plugin_test.py index 1798971..ceef099 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -53,10 +53,6 @@ def test_settings(): ], }) - if django.VERSION < (1, 10): - # for {% ssi %} - the_settings['TEMPLATES'][0]['OPTIONS']['allowed_include_roots'] = [""] - return the_settings diff --git a/tests/test_extends.py b/tests/test_extends.py index a4922db..4b3df69 100644 --- a/tests/test_extends.py +++ b/tests/test_extends.py @@ -3,7 +3,7 @@ """Tests of template inheritance for django_coverage_plugin.""" -from .plugin_test import DjangoPluginTestCase, django_stop_before +from .plugin_test import DjangoPluginTestCase class BlockTest(DjangoPluginTestCase): @@ -146,43 +146,3 @@ def test_include(self): self.assertEqual(text, "First\nInside\nJob\n\nLast\n") self.assert_analysis([1, 2, 3], name="outer.html") self.assert_analysis([1, 2], name="nested.html") - - -# {% ssi %} is in earlier Djangos than 1.9, but doesn't trace properly. -@django_stop_before(1, 10) -class SsiTest(DjangoPluginTestCase): - """Test {% ssi %}, which does not trace the included file.""" - - def test_ssi_unparsed(self): - nested = self.make_template(name="nested.html", text="""\ - Inside {{ a }} - Job - """) - - self.make_template(name="outer.html", text="""\ - First - {% ssi "NESTED" %} - Last - """.replace("NESTED", nested)) - - text = self.run_django_coverage(name="outer.html", context={'a': 17}) - self.assertEqual(text, "First\nInside {{ a }}\nJob\n\nLast\n") - self.assert_analysis([1, 2, 3], name="outer.html") - self.assert_measured_files("outer.html", "nested.html") - - def test_ssi_parsed(self): - nested = self.make_template(name="nested.html", text="""\ - Inside {{ a }} - Job - """) - - self.make_template(name="outer.html", text="""\ - First - {% ssi "NESTED" parsed %} - Last - """.replace("NESTED", nested)) - - text = self.run_django_coverage(name="outer.html", context={'a': 17}) - self.assertEqual(text, "First\nInside 17\nJob\n\nLast\n") - self.assert_analysis([1, 2, 3], name="outer.html") - self.assert_measured_files("outer.html", "nested.html") diff --git a/tox.ini b/tox.ini index 63368b1..5a8304f 100644 --- a/tox.ini +++ b/tox.ini @@ -14,20 +14,17 @@ [tox] envlist = - py27-django{18,111}, - py36-django{18,111,22,32}, - py37-django{22,32}, + py37-django{111,22,32}, py38-django{22,32,40,41,tip}, py39-django{22,32,40,41,tip}, py310-django{32,40,41,tip}, - py311-django{tip}, + py311-django{41,tip}, check,pkgcheck,doc [testenv] deps = pytest unittest-mixins==1.6 - django18: Django>=1.8,<1.9 django111: Django>=1.11,<2.0 django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 @@ -75,8 +72,6 @@ commands = [gh-actions] python = - 2.7: py27 - 3.6: py36 3.7: py37 3.8: py38 3.9: py39 From 68c74080f5ca93c3469d54528d302d4cfc87e4d5 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 4 Dec 2022 06:10:18 -0500 Subject: [PATCH 50/90] refactor(test): oops, this function looked like a test, but is not --- tests/plugin_test.py | 4 ++-- tests/test_settings.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/plugin_test.py b/tests/plugin_test.py index ceef099..d0a1892 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -21,7 +21,7 @@ from django_coverage_plugin.plugin import DjangoTemplatePlugin -def test_settings(): +def get_test_settings(): """Create a dict full of default Django settings for the tests.""" the_settings = { 'CACHES': { @@ -56,7 +56,7 @@ def test_settings(): return the_settings -settings.configure(**test_settings()) +settings.configure(**get_test_settings()) if hasattr(django, "setup"): django.setup() diff --git a/tests/test_settings.py b/tests/test_settings.py index c3ef4d5..4be1636 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -5,18 +5,18 @@ from django.test.utils import override_settings -from .plugin_test import DjangoPluginTestCase, test_settings +from .plugin_test import DjangoPluginTestCase, get_test_settings # Make settings overrides for tests below. NON_DJANGO_BACKEND = 'django.template.backends.dummy.TemplateStrings' -DEBUG_FALSE_OVERRIDES = test_settings() +DEBUG_FALSE_OVERRIDES = get_test_settings() DEBUG_FALSE_OVERRIDES['TEMPLATES'][0]['OPTIONS']['debug'] = False -NO_OPTIONS_OVERRIDES = test_settings() +NO_OPTIONS_OVERRIDES = get_test_settings() del NO_OPTIONS_OVERRIDES['TEMPLATES'][0]['OPTIONS'] -OTHER_ENGINE_OVERRIDES = test_settings() +OTHER_ENGINE_OVERRIDES = get_test_settings() OTHER_ENGINE_OVERRIDES['TEMPLATES'][0]['BACKEND'] = NON_DJANGO_BACKEND OTHER_ENGINE_OVERRIDES['TEMPLATES'][0]['OPTIONS'] = {} From 4ebb2e491908ccc7fb284d52e0af44e6156095d6 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 4 Dec 2022 06:27:41 -0500 Subject: [PATCH 51/90] refactor(test): avoid deprecated method --- tests/test_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_source.py b/tests/test_source.py index 80b53d4..d78449b 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -90,7 +90,7 @@ def test_non_utf8_error(self): self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) self.assert_analysis([1], name="main.html") - with self.assertRaisesRegexp(NoSource, r"changelog.txt.*invalid start byte"): + with self.assertRaisesRegex(NoSource, r"changelog.txt.*invalid start byte"): self.cov.html_report() def test_non_utf8_omitted(self): From 5b19217ff725fb6c32faf7315d53b5da1f001465 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 4 Dec 2022 06:28:03 -0500 Subject: [PATCH 52/90] test: also test on versions of coverage --- tests/banner.py | 6 ++++-- tox.ini | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/banner.py b/tests/banner.py index 9c2fb58..ff6e7aa 100644 --- a/tests/banner.py +++ b/tests/banner.py @@ -5,12 +5,14 @@ import platform +import coverage import django print( - "{} {}; Django {}".format( + "{} {}; Django {}; Coverage {}".format( platform.python_implementation(), platform.python_version(), - django.get_version() + django.get_version(), + coverage.__version__, ) ) diff --git a/tox.ini b/tox.ini index 5a8304f..5a087ef 100644 --- a/tox.ini +++ b/tox.ini @@ -14,23 +14,26 @@ [tox] envlist = - py37-django{111,22,32}, - py38-django{22,32,40,41,tip}, - py39-django{22,32,40,41,tip}, - py310-django{32,40,41,tip}, - py311-django{41,tip}, + py37-django{111,22,32}-cov{5,6,tip}, + py38-django{22,32,40,41,tip}-cov{5,6,tip}, + py39-django{22,32,40,41,tip}-cov{5,6,tip}, + py310-django{32,40,41,tip}-cov{5,6,tip}, + py311-django{41,tip}-cov{6,tip}, check,pkgcheck,doc [testenv] deps = - pytest - unittest-mixins==1.6 + cov5: coverage>=5.0,<6.0 + cov6: coverage>=6.0,<7.0 + covtip: git+https://github.com/nedbat/coveragepy.git django111: Django>=1.11,<2.0 django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 django40: Django>=4.0,<4.1 django41: Django>=4.1,<4.2 - djangotip: https://github.com/django/django/archive/main.tar.gz + djangotip: git+https://github.com/django/django.git + pytest + unittest-mixins==1.6 commands = python -c "import tests.banner" From aa02ed7833abb68fe6b434fb17a4dadf251ef897 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 4 Dec 2022 08:40:34 -0500 Subject: [PATCH 53/90] test: more checks of coverage warnings --- tests/plugin_test.py | 55 +++++++++++++++++++++++++++---------------- tests/test_engines.py | 3 ++- tests/test_simple.py | 13 ++++++---- tests/test_source.py | 7 +++++- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/tests/plugin_test.py b/tests/plugin_test.py index d0a1892..08d152f 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -226,31 +226,52 @@ def get_xml_report(self, name=None): return xml_coverage @contextlib.contextmanager - def assert_plugin_disabled(self, msg): - """Assert that our plugin was disabled during an operation.""" - # self.run_django_coverage will raise PluginDisabled if the plugin - # was disabled. + def assert_coverage_warnings(self, *msgs, min_cov=None): + """Assert that coverage.py warnings are raised that contain all msgs. + + If coverage version isn't at least min_cov, then no warnings are expected. + + """ # Coverage.py 6.0 made the warnings real warnings, so we have to adapt # how we test the warnings based on the version. - if coverage.version.version_info >= (6, 0): + if min_cov is not None and coverage.version_info < min_cov: + # Don't check for warnings on lower versions of coverage + yield + return + elif coverage.version_info >= (6, 0): import coverage.exceptions as cov_exc ctxmgr = self.assertWarns(cov_exc.CoverageWarning) else: - ctxmgr = nullcontext() + ctxmgr = contextlib.nullcontext() with ctxmgr as cw: - with self.assertRaises(PluginDisabled): - yield + yield if cw is not None: warn_text = "\n".join(str(w.message) for w in cw.warnings) else: warn_text = self.stderr() - self.assertIn( - "Disabling plug-in 'django_coverage_plugin.DjangoTemplatePlugin' " - "due to an exception:", - warn_text - ) - self.assertIn("DjangoTemplatePluginException: " + msg, warn_text) + for msg in msgs: + self.assertIn(msg, warn_text) + + @contextlib.contextmanager + def assert_plugin_disabled(self, msg): + """Assert that our plugin was disabled during an operation.""" + # self.run_django_coverage will raise PluginDisabled if the plugin + # was disabled. + msgs = [ + "Disabling plug-in 'django_coverage_plugin.DjangoTemplatePlugin' due to an exception:", + "DjangoTemplatePluginException: " + msg, + ] + with self.assert_coverage_warnings(*msgs): + with self.assertRaises(PluginDisabled): + yield + + @contextlib.contextmanager + def assert_no_data(self, min_cov=None): + """Assert that coverage warns no data was collected.""" + warn_msg = "No data was collected. (no-data-collected)" + with self.assert_coverage_warnings(warn_msg, min_cov=min_cov): + yield def squashed(s): @@ -289,9 +310,3 @@ def test_thing(self): class PluginDisabled(Exception): """Raised if we find that our plugin has been disabled.""" pass - - -@contextlib.contextmanager -def nullcontext(): - """For when we need a context manager to do nothing.""" - yield None diff --git a/tests/test_engines.py b/tests/test_engines.py index 76c713f..213d59e 100644 --- a/tests/test_engines.py +++ b/tests/test_engines.py @@ -33,7 +33,8 @@ def test_file_template(self): self.assert_analysis([1]) def test_string_template(self): - text = self.run_django_coverage(text='Hello', using='other') + with self.assert_no_data(): + text = self.run_django_coverage(text='Hello', using='other') self.assertEqual(text, 'Hello') def test_third_engine_not_debug(self): diff --git a/tests/test_simple.py b/tests/test_simple.py index 7ca9188..225a095 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -245,11 +245,14 @@ class StringTemplateTest(DjangoPluginTestCase): run_in_temp_dir = False def test_string_template(self): - text = self.run_django_coverage( - text="Hello, {{name}}!", - context={'name': 'World'}, - options={}, - ) + # I don't understand why coverage 6 warns about no data, + # but coverage 5 does not. + with self.assert_no_data(min_cov=(6, 0)): + text = self.run_django_coverage( + text="Hello, {{name}}!", + context={'name': 'World'}, + options={}, + ) self.assertEqual(text, "Hello, World!") diff --git a/tests/test_source.py b/tests/test_source.py index d78449b..229a9b8 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -133,7 +133,12 @@ def test_non_utf8_ignored(self): self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) self.assert_analysis([1], name="main.html") - self.cov.html_report() + warn_msg = ( + "'utf-8' codec can't decode byte 0xf6 in position 2: " + + "invalid start byte (couldnt-parse)" + ) + with self.assert_coverage_warnings(warn_msg, min_cov=(6, 0)): + self.cov.html_report() def test_htmlcov_isnt_measured(self): # We used to find the HTML report and think it was template files. From 7c2f9fc2f9baf6d7df372ba1f50cd60e299514c4 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 4 Dec 2022 11:37:12 -0500 Subject: [PATCH 54/90] refactor: pyupgrade --py37-plus --- django_coverage_plugin/plugin.py | 15 +++++++-------- setup.py | 3 +-- tests/plugin_test.py | 8 ++++---- tests/test_engines.py | 2 +- tests/test_html.py | 1 - tests/test_simple.py | 11 +++++------ tests/test_source.py | 6 +++--- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index df07f2f..6a0a720 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -17,7 +17,6 @@ from django.template.base import Lexer, NodeList, Template, TextNode from django.template.defaulttags import VerbatimNode from django.templatetags.i18n import BlockTranslateNode -from six.moves import range try: from django.template.base import TokenType @@ -165,7 +164,7 @@ def sys_info(self): return [ ("django_template_dir", self.django_template_dir), ("environment", sorted( - ("%s = %s" % (k, v)) + ("{} = {}".format(k, v)) for k, v in os.environ.items() if "DJANGO" in k )), @@ -239,7 +238,7 @@ def line_number_range(self, frame): return -1, -1 if SHOW_TRACING: - print("{!r}: {}".format(render_self, position)) + print(f"{render_self!r}: {position}") s_start, s_end = position if isinstance(render_self, TextNode): first_line = render_self.s.splitlines(True)[0] @@ -294,7 +293,7 @@ def get_line_map(self, filename): class FileReporter(coverage.plugin.FileReporter): def __init__(self, filename): - super(FileReporter, self).__init__(filename) + super().__init__(filename) # TODO: html filenames are absolute. self._source = None @@ -303,15 +302,15 @@ def source(self): if self._source is None: try: self._source = read_template_source(self.filename) - except (IOError, UnicodeError) as exc: - raise NoSource("Couldn't read {}: {}".format(self.filename, exc)) + except (OSError, UnicodeError) as exc: + raise NoSource(f"Couldn't read {self.filename}: {exc}") return self._source def lines(self): source_lines = set() if SHOW_PARSING: - print("-------------- {}".format(self.filename)) + print(f"-------------- {self.filename}") if django.VERSION >= (1, 9): lexer = Lexer(self.source()) @@ -389,7 +388,7 @@ def lines(self): source_lines.update(range(lineno, lineno+num_lines)) if SHOW_PARSING: - print("\t\t\tNow source_lines is: {!r}".format(source_lines)) + print(f"\t\t\tNow source_lines is: {source_lines!r}") return source_lines diff --git a/setup.py b/setup.py index 3e8ca40..ed86f29 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,6 @@ """ -import io import re from os.path import dirname, join @@ -19,7 +18,7 @@ def read(*names, **kwargs): Parameter: encoding kwarg may be set """ - return io.open( + return open( join(dirname(__file__), *names), encoding=kwargs.get('encoding', 'utf8') ).read() diff --git a/tests/plugin_test.py b/tests/plugin_test.py index 08d152f..cc90be8 100644 --- a/tests/plugin_test.py +++ b/tests/plugin_test.py @@ -66,11 +66,11 @@ class DjangoPluginTestCase(StdStreamCapturingMixin, TempDirMixin, TestCase): """A base class for all our tests.""" def setUp(self): - super(DjangoPluginTestCase, self).setUp() + super().setUp() self.template_directory = "templates" def _path(self, name=None): - return "{}/{}".format(self.template_directory, name or self.template_file) + return f"{self.template_directory}/{name or self.template_file}" def make_template(self, text, name=None): """Make a template with `text`. @@ -191,14 +191,14 @@ def assert_analysis(self, executable, missing=None, name=None): self.assertEqual( executable, actual_executable, - "Executable lines aren't as expected: %r != %r" % ( + "Executable lines aren't as expected: {!r} != {!r}".format( executable, actual_executable, ), ) self.assertEqual( missing or [], actual_missing, - "Missing lines aren't as expected: %r != %r" % ( + "Missing lines aren't as expected: {!r} != {!r}".format( missing, actual_missing, ), ) diff --git a/tests/test_engines.py b/tests/test_engines.py index 213d59e..fdaa2ca 100644 --- a/tests/test_engines.py +++ b/tests/test_engines.py @@ -10,7 +10,7 @@ class MultipleEngineTests(DjangoPluginTestCase): def setUp(self): - super(MultipleEngineTests, self).setUp() + super().setUp() engine = { 'NAME': 'other', diff --git a/tests/test_html.py b/tests/test_html.py index c22ac00..5038468 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1,4 +1,3 @@ -# coding: utf8 # 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 diff --git a/tests/test_simple.py b/tests/test_simple.py index 225a095..a09ecb7 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -1,4 +1,3 @@ -# coding: utf8 # 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 @@ -7,7 +6,7 @@ from .plugin_test import DjangoPluginTestCase # 200 Unicode chars: snowman + poo. -UNIUNI = u"\u26C4\U0001F4A9"*100 +UNIUNI = "\u26C4\U0001F4A9"*100 if isinstance(UNIUNI, str): UNISTR = UNIUNI else: @@ -64,8 +63,8 @@ def test_non_ascii(self): υηιcσɗє ιѕ тяιcку {{more}}! """) - text = self.run_django_coverage(context={'more': u'ɘboɔinU'}) - self.assertEqual(text, u'υηιcσɗє ιѕ тяιcку\nɘboɔinU!\n') + text = self.run_django_coverage(context={'more': 'ɘboɔinU'}) + self.assertEqual(text, 'υηιcσɗє ιѕ тяιcку\nɘboɔinU!\n') self.assert_analysis([1, 2]) self.assertEqual(self.get_html_report(), 100) self.assertEqual(self.get_xml_report(), 100) @@ -215,8 +214,8 @@ def test_verbatim(self): text = self.run_django_coverage() self.assertEqual( text, - u"1\n\n{{if dying}}Alive.{{/if}}\nsecond.\n" - u"{%third%}.UNIUNI\n\n7\n".replace(u"UNIUNI", UNIUNI) + "1\n\n{{if dying}}Alive.{{/if}}\nsecond.\n" + "{%third%}.UNIUNI\n\n7\n".replace("UNIUNI", UNIUNI) ) self.assert_analysis([1, 2, 3, 4, 5, 7]) diff --git a/tests/test_source.py b/tests/test_source.py index 229a9b8..6313504 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -88,7 +88,7 @@ def test_non_utf8_error(self): text = self.run_django_coverage(name="main.html") self.assertEqual(text, "Hello") - self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) + self.assert_measured_files("main.html", f"static{os.sep}changelog.txt") self.assert_analysis([1], name="main.html") with self.assertRaisesRegex(NoSource, r"changelog.txt.*invalid start byte"): self.cov.html_report() @@ -110,7 +110,7 @@ def test_non_utf8_omitted(self): text = self.run_django_coverage(name="main.html") self.assertEqual(text, "Hello") - self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) + self.assert_measured_files("main.html", f"static{os.sep}changelog.txt") self.assert_analysis([1], name="main.html") self.cov.html_report() @@ -131,7 +131,7 @@ def test_non_utf8_ignored(self): text = self.run_django_coverage(name="main.html") self.assertEqual(text, "Hello") - self.assert_measured_files("main.html", "static{}changelog.txt".format(os.sep)) + self.assert_measured_files("main.html", f"static{os.sep}changelog.txt") self.assert_analysis([1], name="main.html") warn_msg = ( "'utf-8' codec can't decode byte 0xf6 in position 2: " + From 09ed8b4d8ab2c6e29fa8b3fce41290f6750ac5fc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 4 Dec 2022 11:47:27 -0500 Subject: [PATCH 55/90] test: ci should cancel older jobs --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14bf40d..24cb6a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,11 +12,18 @@ on: # week, Sundays at 6:00 UTC. - cron: "0 6 * * 0" +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true defaults: run: shell: bash +env: + PIP_DISABLE_PIP_VERSION_CHECK: 1 + FORCE_COLOR: 1 # Get colored pytest output + jobs: tests: name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}" From c35d4b694d1f1e039612fdd2d00a719aa2a899ea Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 6 Dec 2022 04:51:01 -0500 Subject: [PATCH 56/90] refactor: no need for six anymore --- .isort.cfg | 2 +- setup.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index ed14f2e..cd31999 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -4,4 +4,4 @@ force_grid_wrap=0 include_trailing_comma=True line_length=79 multi_line_output=3 -known_third_party = coverage,django,setuptools,six,unittest_mixins +known_third_party = coverage,django,setuptools,unittest_mixins diff --git a/setup.py b/setup.py index ed86f29..49d29a6 100644 --- a/setup.py +++ b/setup.py @@ -64,7 +64,6 @@ def read(*names, **kwargs): packages=['django_coverage_plugin'], install_requires=[ 'coverage', - 'six >= 1.4.0', ], license='Apache-2.0', classifiers=classifiers.splitlines(), From 733514a5caf03bc152f52057f41a9528c8232f64 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 6 Dec 2022 04:56:26 -0500 Subject: [PATCH 57/90] build: 3.0.0 --- README.rst | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index ce3a935..13f091c 100644 --- a/README.rst +++ b/README.rst @@ -137,8 +137,8 @@ History .. scriv-insert-here -Next ----- +v3.0.0 — 2022-12-06 +------------------- Dropped support for Python 2.7, Python 3.6, and Django 1.8. diff --git a/setup.py b/setup.py index 49d29a6..579114f 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def read(*names, **kwargs): setup( name='django_coverage_plugin', - version='2.0.4', + version='3.0.0', description='Django template coverage.py plugin', long_description=( re.sub( From bc067032dd675a705ead621afaea0c34fde1247f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 22 Jan 2023 09:10:16 -0500 Subject: [PATCH 58/90] test: django tip dropped support for 3.8 and 3.9 I'm not sure why they did, but they did. --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 5a087ef..70494ec 100644 --- a/tox.ini +++ b/tox.ini @@ -15,8 +15,8 @@ [tox] envlist = py37-django{111,22,32}-cov{5,6,tip}, - py38-django{22,32,40,41,tip}-cov{5,6,tip}, - py39-django{22,32,40,41,tip}-cov{5,6,tip}, + py38-django{22,32,40,41}-cov{5,6,tip}, + py39-django{22,32,40,41}-cov{5,6,tip}, py310-django{32,40,41,tip}-cov{5,6,tip}, py311-django{41,tip}-cov{6,tip}, check,pkgcheck,doc From b821fc670d8b4ebb03080aa869bccb1cb1157bb3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 30 Apr 2023 06:35:51 -0400 Subject: [PATCH 59/90] build: update the tox envs for Django 4.2 and coverage 7.x --- tox.ini | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tox.ini b/tox.ini index 70494ec..2451ca4 100644 --- a/tox.ini +++ b/tox.ini @@ -14,23 +14,22 @@ [tox] envlist = - py37-django{111,22,32}-cov{5,6,tip}, - py38-django{22,32,40,41}-cov{5,6,tip}, - py39-django{22,32,40,41}-cov{5,6,tip}, - py310-django{32,40,41,tip}-cov{5,6,tip}, - py311-django{41,tip}-cov{6,tip}, + py37-django{111,22,32}-cov{6,7,tip}, + py38-django{22,32,42}-cov{6,7,tip}, + 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}, check,pkgcheck,doc [testenv] deps = - cov5: coverage>=5.0,<6.0 cov6: coverage>=6.0,<7.0 + cov7: coverage>=7.0,<8.0 covtip: git+https://github.com/nedbat/coveragepy.git django111: Django>=1.11,<2.0 django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 - django40: Django>=4.0,<4.1 - django41: Django>=4.1,<4.2 + django42: Django>=4.2,<5.0 djangotip: git+https://github.com/django/django.git pytest unittest-mixins==1.6 From 8d6c1032b443b3d48a57d77e9690d18d430d5974 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 9 Jul 2023 07:18:04 -0400 Subject: [PATCH 60/90] build: drop support for 3.7 and Django 1.x --- .github/workflows/tests.yml | 3 +-- README.rst | 6 +++--- django_coverage_plugin/plugin.py | 9 +++------ setup.py | 3 +-- tox.ini | 3 --- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 24cb6a1..a3bbb7a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,7 +38,6 @@ 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.7" - "3.8" - "3.9" - "3.10" @@ -86,7 +85,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v2" with: - python-version: "3.7" + python-version: "3.8" - name: "Install dependencies" run: | diff --git a/README.rst b/README.rst index 13f091c..5a68ce0 100644 --- a/README.rst +++ b/README.rst @@ -31,11 +31,11 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. Supported on: -- Python: 3.7 through 3.11. +- Python: 3.8 through 3.11. -- Django: 1.11, 2.x, 3.x and 4.x. +- Django: 2.x, 3.x and 4.x. -- Coverage.py: 4.x or higher. +- Coverage.py: 6.x or higher. The plugin is pip installable:: diff --git a/django_coverage_plugin/plugin.py b/django_coverage_plugin/plugin.py index 6a0a720..158ee9a 100644 --- a/django_coverage_plugin/plugin.py +++ b/django_coverage_plugin/plugin.py @@ -96,8 +96,8 @@ def check_debug(): return True -if django.VERSION < (1, 11): - raise RuntimeError("Django Coverage Plugin requires Django 1.11 or higher") +if django.VERSION < (2, 0): + raise RuntimeError("Django Coverage Plugin requires Django 2.x or higher") # Since we are grabbing at internal details, we have to adapt as they @@ -312,10 +312,7 @@ def lines(self): if SHOW_PARSING: print(f"-------------- {self.filename}") - if django.VERSION >= (1, 9): - lexer = Lexer(self.source()) - else: - lexer = Lexer(self.source(), self.filename) + lexer = Lexer(self.source()) tokens = lexer.tokenize() # Are we inside a comment? diff --git a/setup.py b/setup.py index 579114f..99d3863 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,6 @@ def read(*names, **kwargs): Intended Audience :: Developers License :: OSI Approved :: Apache Software License Operating System :: OS Independent -Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -43,7 +42,7 @@ def read(*names, **kwargs): Framework :: Django :: 1.11 Framework :: Django :: 2.2 Framework :: Django :: 3.2 -Framework :: Django :: 4.1 +Framework :: Django :: 4.2 """ setup( diff --git a/tox.ini b/tox.ini index 2451ca4..7be8aeb 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,6 @@ [tox] envlist = - py37-django{111,22,32}-cov{6,7,tip}, py38-django{22,32,42}-cov{6,7,tip}, py39-django{22,32,42}-cov{6,7,tip}, py310-django{32,42,tip}-cov{6,7,tip}, @@ -26,7 +25,6 @@ deps = cov6: coverage>=6.0,<7.0 cov7: coverage>=7.0,<8.0 covtip: git+https://github.com/nedbat/coveragepy.git - django111: Django>=1.11,<2.0 django22: Django>=2.2,<3.0 django32: Django>=3.2,<4.0 django42: Django>=4.2,<5.0 @@ -74,7 +72,6 @@ commands = [gh-actions] python = - 3.7: py37 3.8: py38 3.9: py39 3.10: py310 From f829489edd5cfb59ca0e1449065778466239de10 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 9 Jul 2023 07:47:30 -0400 Subject: [PATCH 61/90] test: modernize some workflow stuff --- .github/workflows/tests.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a3bbb7a..ee74070 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,6 +12,9 @@ on: # week, Sundays at 6:00 UTC. - cron: "0 6 * * 0" +permissions: + contents: read + concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true @@ -26,15 +29,15 @@ env: jobs: tests: - name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}" - runs-on: "${{ matrix.os }}" + name: "${{ matrix.python-version }} on ${{ matrix.os }}" + runs-on: "${{ matrix.os }}-latest" strategy: matrix: os: - - ubuntu-latest - - macos-latest - - windows-latest + - ubuntu + - macos + - windows python-version: # When changing this list, be sure to check the [gh-actions] list in # tox.ini so that tox will run properly. @@ -46,12 +49,13 @@ jobs: steps: - name: "Check out the repo" - uses: "actions/checkout@v2" + uses: "actions/checkout@v3" - name: "Set up Python" - uses: "actions/setup-python@v2" + uses: "actions/setup-python@v4" with: python-version: "${{ matrix.python-version }}" + allow-prereleases: true - name: "Install dependencies" run: | From e0bce92fa394c7c398ab20a4d0a2cffe8caaac02 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 9 Jul 2023 07:42:57 -0400 Subject: [PATCH 62/90] build: test on 3.12 --- .github/workflows/tests.yml | 1 + README.rst | 6 +++--- setup.py | 1 + tox.ini | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ee74070..e7f50b7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,6 +45,7 @@ jobs: - "3.9" - "3.10" - "3.11" + - "3.12" fail-fast: false steps: diff --git a/README.rst b/README.rst index 5a68ce0..59bd59f 100644 --- a/README.rst +++ b/README.rst @@ -31,7 +31,7 @@ A `coverage.py`_ plugin to measure test coverage of Django templates. Supported on: -- Python: 3.8 through 3.11. +- Python: 3.8 through 3.12. - Django: 2.x, 3.x and 4.x. @@ -39,7 +39,7 @@ Supported on: The plugin is pip installable:: - $ pip install django_coverage_plugin + $ python3 -m pip install django_coverage_plugin To run it, add this setting to your ``.coveragerc`` file:: @@ -128,7 +128,7 @@ Tests To run the tests:: - $ pip install -r requirements.txt + $ python3 -m pip install -r requirements.txt $ tox diff --git a/setup.py b/setup.py index 99d3863..f4367ae 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ def read(*names, **kwargs): Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 +Programming Language :: Python :: 3.12 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy Topic :: Software Development :: Quality Assurance diff --git a/tox.ini b/tox.ini index 7be8aeb..5c01601 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ envlist = 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}, check,pkgcheck,doc [testenv] @@ -76,3 +77,4 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 From 3e09c0daf3ed70558773baa519c4bf8dc7249a11 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 10 Jul 2023 09:13:51 -0400 Subject: [PATCH 63/90] build: 3.1.0 --- README.rst | 8 ++++++++ setup.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 59bd59f..7ce3fd4 100644 --- a/README.rst +++ b/README.rst @@ -137,6 +137,13 @@ History .. scriv-insert-here +v3.1.0 — 2023-07-10 +------------------- + +Dropped support for Python 3.7 and Django 1.x. Declared support for Python +3.12. + + v3.0.0 — 2022-12-06 ------------------- @@ -148,6 +155,7 @@ v2.0.4 — 2022-10-31 Declare our support for Python 3.11 and Django 4.1. + v2.0.3 — 2022-05-04 ------------------- diff --git a/setup.py b/setup.py index f4367ae..0132d17 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def read(*names, **kwargs): setup( name='django_coverage_plugin', - version='3.0.0', + version='3.1.0', description='Django template coverage.py plugin', long_description=( re.sub( From ca45852f7168d36b69e6a64f01d804b572775680 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 27 Jan 2024 06:33:00 -0500 Subject: [PATCH 64/90] build: ensure tags are signed even if commits are not --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 39992d8..85fc6c6 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ kit_upload: ## Upload the built distributions to PyPI. python -m twine upload --verbose dist/* tag: ## Make a git tag with the version number. - git tag -a -m "Version v$$(python setup.py --version)" v$$(python setup.py --version) + git tag -s -m "Version v$$(python setup.py --version)" v$$(python setup.py --version) git push --all ghrelease: ## Make a GitHub release for the latest version. From b792d7d4102e45d1f31548ef4b0a826ea0d2155e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 28 Oct 2024 10:53:47 -0400 Subject: [PATCH 65/90] 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 66/90] 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 67/90] 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 68/90] 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 69/90] 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 70/90] 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 71/90] 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 72/90] 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 73/90] 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 74/90] 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 75/90] 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 76/90] 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 77/90] 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 78/90] 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 79/90] 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 80/90] 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 81/90] 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 82/90] 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 83/90] 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 84/90] 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 85/90] 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 86/90] 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 87/90] 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 88/90] 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 89/90] 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 90/90] 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__"}