Skip to content

Commit 739306f

Browse files
committed
refactor: drop support for py<3.7 and django<1.11
1 parent 003b6d0 commit 739306f

File tree

8 files changed

+28
-97
lines changed

8 files changed

+28
-97
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,11 @@ jobs:
3131
python-version:
3232
# When changing this list, be sure to check the [gh-actions] list in
3333
# tox.ini so that tox will run properly.
34-
- "2.7"
35-
- "3.6"
3634
- "3.7"
3735
- "3.8"
3836
- "3.9"
3937
- "3.10"
4038
- "3.11"
41-
exclude:
42-
# Windows 2.7 doesn't work because Microsoft removed stuff we needed.
43-
- os: windows-latest
44-
python-version: "2.7"
4539
fail-fast: false
4640

4741
steps:
@@ -85,7 +79,7 @@ jobs:
8579
- name: "Set up Python"
8680
uses: "actions/setup-python@v2"
8781
with:
88-
python-version: "3.8"
82+
python-version: "3.7"
8983

9084
- name: "Install dependencies"
9185
run: |

README.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ A `coverage.py`_ plugin to measure test coverage of Django templates.
3131
3232
Supported on:
3333

34-
- Python: 2.7, and 3.6 through 3.11.
34+
- Python: 3.7 through 3.11.
3535

36-
- Django: 1.8, 1.11, 2.x, 3.x and 4.x.
36+
- Django: 1.11, 2.x, 3.x and 4.x.
3737

3838
- Coverage.py: 4.x or higher.
3939

@@ -137,6 +137,12 @@ History
137137

138138
.. scriv-insert-here
139139
140+
Next
141+
----
142+
143+
Dropped support for Python 2.7, Python 3.6, and Django 1.8.
144+
145+
140146
v2.0.4 — 2022-10-31
141147
-------------------
142148

django_coverage_plugin/plugin.py

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
"""The Django template coverage plugin."""
55

6-
from __future__ import print_function
7-
86
import os.path
97
import re
108

@@ -99,39 +97,28 @@ def check_debug():
9997
return True
10098

10199

102-
if django.VERSION < (1, 8):
103-
raise RuntimeError("Django Coverage Plugin requires Django 1.8 or higher")
100+
if django.VERSION < (1, 11):
101+
raise RuntimeError("Django Coverage Plugin requires Django 1.11 or higher")
104102

105103

106-
if django.VERSION >= (1, 9):
107-
# Since we are grabbing at internal details, we have to adapt as they
108-
# change over versions.
109-
def filename_for_frame(frame):
110-
try:
111-
return frame.f_locals["self"].origin.name
112-
except (KeyError, AttributeError):
113-
return None
104+
# Since we are grabbing at internal details, we have to adapt as they
105+
# change over versions.
106+
def filename_for_frame(frame):
107+
try:
108+
return frame.f_locals["self"].origin.name
109+
except (KeyError, AttributeError):
110+
return None
114111

115-
def position_for_node(node):
116-
try:
117-
return node.token.position
118-
except AttributeError:
119-
return None
120112

121-
def position_for_token(token):
122-
return token.position
123-
else:
124-
def filename_for_frame(frame):
125-
try:
126-
return frame.f_locals["self"].source[0].name
127-
except (KeyError, AttributeError, IndexError):
128-
return None
113+
def position_for_node(node):
114+
try:
115+
return node.token.position
116+
except AttributeError:
117+
return None
129118

130-
def position_for_node(node):
131-
return node.source[1]
132119

133-
def position_for_token(token):
134-
return token.source[1]
120+
def position_for_token(token):
121+
return token.position
135122

136123

137124
def read_template_source(filename):

setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env python
2-
# -*- encoding: utf-8 -*-
32
"""Setup for Django Coverage Plugin
43
54
Licensed under the Apache 2.0 License
65
- http://www.apache.org/licenses/LICENSE-2.0
76
- https://github.com/nedbat/django_coverage_plugin/blob/master/NOTICE.txt
87
98
"""
10-
from __future__ import absolute_import, print_function
119

1210
import io
1311
import re
@@ -32,8 +30,6 @@ def read(*names, **kwargs):
3230
Intended Audience :: Developers
3331
License :: OSI Approved :: Apache Software License
3432
Operating System :: OS Independent
35-
Programming Language :: Python :: 2.7
36-
Programming Language :: Python :: 3.6
3733
Programming Language :: Python :: 3.7
3834
Programming Language :: Python :: 3.8
3935
Programming Language :: Python :: 3.9
@@ -45,7 +41,6 @@ def read(*names, **kwargs):
4541
Topic :: Software Development :: Testing
4642
Development Status :: 5 - Production/Stable
4743
Framework :: Django
48-
Framework :: Django :: 1.8
4944
Framework :: Django :: 1.11
5045
Framework :: Django :: 2.2
5146
Framework :: Django :: 3.2

tests/banner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
"""For printing the versions from tox.ini."""
55

6-
from __future__ import print_function
7-
86
import platform
97

108
import django

tests/plugin_test.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ def test_settings():
5353
],
5454
})
5555

56-
if django.VERSION < (1, 10):
57-
# for {% ssi %}
58-
the_settings['TEMPLATES'][0]['OPTIONS']['allowed_include_roots'] = [""]
59-
6056
return the_settings
6157

6258

tests/test_extends.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""Tests of template inheritance for django_coverage_plugin."""
55

6-
from .plugin_test import DjangoPluginTestCase, django_stop_before
6+
from .plugin_test import DjangoPluginTestCase
77

88

99
class BlockTest(DjangoPluginTestCase):
@@ -146,43 +146,3 @@ def test_include(self):
146146
self.assertEqual(text, "First\nInside\nJob\n\nLast\n")
147147
self.assert_analysis([1, 2, 3], name="outer.html")
148148
self.assert_analysis([1, 2], name="nested.html")
149-
150-
151-
# {% ssi %} is in earlier Djangos than 1.9, but doesn't trace properly.
152-
@django_stop_before(1, 10)
153-
class SsiTest(DjangoPluginTestCase):
154-
"""Test {% ssi %}, which does not trace the included file."""
155-
156-
def test_ssi_unparsed(self):
157-
nested = self.make_template(name="nested.html", text="""\
158-
Inside {{ a }}
159-
Job
160-
""")
161-
162-
self.make_template(name="outer.html", text="""\
163-
First
164-
{% ssi "NESTED" %}
165-
Last
166-
""".replace("NESTED", nested))
167-
168-
text = self.run_django_coverage(name="outer.html", context={'a': 17})
169-
self.assertEqual(text, "First\nInside {{ a }}\nJob\n\nLast\n")
170-
self.assert_analysis([1, 2, 3], name="outer.html")
171-
self.assert_measured_files("outer.html", "nested.html")
172-
173-
def test_ssi_parsed(self):
174-
nested = self.make_template(name="nested.html", text="""\
175-
Inside {{ a }}
176-
Job
177-
""")
178-
179-
self.make_template(name="outer.html", text="""\
180-
First
181-
{% ssi "NESTED" parsed %}
182-
Last
183-
""".replace("NESTED", nested))
184-
185-
text = self.run_django_coverage(name="outer.html", context={'a': 17})
186-
self.assertEqual(text, "First\nInside 17\nJob\n\nLast\n")
187-
self.assert_analysis([1, 2, 3], name="outer.html")
188-
self.assert_measured_files("outer.html", "nested.html")

tox.ini

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@
1414

1515
[tox]
1616
envlist =
17-
py27-django{18,111},
18-
py36-django{18,111,22,32},
19-
py37-django{22,32},
17+
py37-django{111,22,32},
2018
py38-django{22,32,40,41,tip},
2119
py39-django{22,32,40,41,tip},
2220
py310-django{32,40,41,tip},
23-
py311-django{tip},
21+
py311-django{41,tip},
2422
check,pkgcheck,doc
2523

2624
[testenv]
2725
deps =
2826
pytest
2927
unittest-mixins==1.6
30-
django18: Django>=1.8,<1.9
3128
django111: Django>=1.11,<2.0
3229
django22: Django>=2.2,<3.0
3330
django32: Django>=3.2,<4.0
@@ -75,8 +72,6 @@ commands =
7572

7673
[gh-actions]
7774
python =
78-
2.7: py27
79-
3.6: py36
8075
3.7: py37
8176
3.8: py38
8277
3.9: py39

0 commit comments

Comments
 (0)