Skip to content

Commit 570677c

Browse files
author
Pamela McA'Nulty
committed
Merge master
1 parent 877306a commit 570677c

File tree

10 files changed

+66
-483
lines changed

10 files changed

+66
-483
lines changed

README.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A `coverage.py`_ plugin to measure the coverage of Django templates.
1414
1515
Supported Python versions are 2.7, 3.4, 3.5 and 3.6.
1616

17-
Supported Django versions are 1.4 through 1.10.
17+
Supported Django versions are 1.8 through 1.11b1.
1818

1919
Supported coverage.py versions are 4.0 and higher.
2020

@@ -49,8 +49,6 @@ template files are included in the report.
4949
Caveats
5050
~~~~~~~
5151

52-
Support for Django versions 1.4 through 1.7 should be considered deprecated.
53-
5452
Files included by the ``{% ssi %}`` tag are not included in the coverage
5553
measurements.
5654

@@ -61,6 +59,12 @@ plural text, so both are marked as used if the tag is used.
6159
Changes
6260
~~~~~~~
6361

62+
63+
v1.4.3 --- 2017-02-22
64+
---------------------
65+
66+
Removes support for Django versions below 1.8. Validates support for Django version 1.11b1
67+
6468
v1.4.2 --- 2017-02-06
6569
---------------------
6670

@@ -179,7 +183,7 @@ To run the tests::
179183
.. |versions| image:: https://img.shields.io/pypi/pyversions/django_coverage_plugin.svg
180184
:target: https://pypi.python.org/pypi/django_coverage_plugin
181185
:alt: Python versions supported
182-
.. |djversions| image:: https://img.shields.io/badge/Django-1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10-44b78b.svg
186+
.. |djversions| image:: https://img.shields.io/badge/Django-1.8, 1.9, 1.10, 1.11.svg
183187
:target: https://pypi.python.org/pypi/django_coverage_plugin
184188
:alt: Django versions supported
185189
.. |status| image:: https://img.shields.io/pypi/status/django_coverage_plugin.svg

django_coverage_plugin/plugin.py

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,44 +49,27 @@ def check_debug():
4949
if not settings.configured:
5050
return False
5151

52-
if django.VERSION >= (1, 8):
53-
54-
from django.apps import apps
55-
if not apps.ready:
56-
return False
57-
58-
# Django 1.8+ handles both old and new-style settings and converts them
59-
# into template engines, so we don't need to depend on settings values
60-
# directly and can look at the resulting configured objects
61-
62-
# I _think_ this check is all that's needed and the 3 "hasattr" checks
63-
# below can be removed, but it's not clear how to verify that
64-
from django.apps import apps
65-
if not apps.ready:
66-
return False
67-
68-
# django.template.backends.django gets loaded lazily, so return false
69-
# until they've been loaded
70-
if not hasattr(django.template, "backends"):
71-
return False
72-
if not hasattr(django.template.backends, "django"):
73-
return False
74-
75-
if not hasattr(django.template.backends.django, "DjangoTemplates"):
76-
raise DjangoTemplatePluginException("Can't use non-Django templates.")
77-
78-
for engine in django.template.engines.all():
79-
if not isinstance(engine, django.template.backends.django.DjangoTemplates):
80-
raise DjangoTemplatePluginException(
81-
"Can't use non-Django templates."
82-
)
83-
if not engine.engine.debug:
84-
raise DjangoTemplatePluginException(
85-
"Template debugging must be enabled in settings."
86-
)
87-
else:
88-
# Old-style settings.
89-
if not settings.TEMPLATE_DEBUG:
52+
# I _think_ this check is all that's needed and the 3 "hasattr" checks
53+
# below can be removed, but it's not clear how to verify that
54+
from django.apps import apps
55+
if not apps.ready:
56+
return False
57+
58+
# django.template.backends.django gets loaded lazily, so return false
59+
# until they've been loaded
60+
if not hasattr(django.template, "backends"):
61+
return False
62+
if not hasattr(django.template.backends, "django"):
63+
return False
64+
if not hasattr(django.template.backends.django, "DjangoTemplates"):
65+
raise DjangoTemplatePluginException("Can't use non-Django templates.")
66+
67+
for engine in django.template.engines.all():
68+
if not isinstance(engine, django.template.backends.django.DjangoTemplates):
69+
raise DjangoTemplatePluginException(
70+
"Can't use non-Django templates."
71+
)
72+
if not engine.engine.debug:
9073
raise DjangoTemplatePluginException(
9174
"Template debugging must be enabled in settings."
9275
)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
setup(
2424
name='django_coverage_plugin',
25-
version='1.4.2',
25+
version='1.4.3',
2626
description='Django template coverage.py plugin',
2727
author='Ned Batchelder',
2828
author_email='[email protected]',
2929
url='https://github.com/nedbat/django_coverage_plugin',
3030
packages=['django_coverage_plugin'],
3131
install_requires=[
32-
'Django >= 1.4',
32+
'Django >= 1.8',
3333
'coverage >= 4.0',
3434
'six >= 1.4.0',
3535
],

tests/plugin_test.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,22 @@ def test_settings():
3535
'ROOT_URLCONF': 'tests',
3636
}
3737

38-
if django.VERSION >= (1, 8):
39-
the_settings.update({
40-
'TEMPLATES': [
41-
{
42-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
43-
'DIRS': ['templates'], # where the tests put things.
44-
'OPTIONS': {
45-
'debug': True,
46-
},
38+
the_settings.update({
39+
'TEMPLATES': [
40+
{
41+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
42+
'DIRS': ['templates'], # where the tests put things.
43+
'OPTIONS': {
44+
'debug': True,
4745
},
48-
],
49-
})
46+
},
47+
],
48+
})
5049

51-
if django.VERSION < (1, 10):
52-
# for {% ssi %}
53-
the_settings['TEMPLATES'][0]['OPTIONS']['allowed_include_roots'] = ['/']
50+
if django.VERSION < (1, 10):
51+
# for {% ssi %}
52+
the_settings['TEMPLATES'][0]['OPTIONS']['allowed_include_roots'] = ['/']
5453

55-
else:
56-
the_settings.update({
57-
'ALLOWED_INCLUDE_ROOTS': ['/'], # for {% ssi %}
58-
'TEMPLATE_DEBUG': True,
59-
'TEMPLATE_DIRS': ['templates'], # where the tests put things.
60-
})
6154

6255
return the_settings
6356

@@ -68,12 +61,10 @@ def test_settings():
6861
django.setup()
6962

7063
from django.template import Context, Template # noqa
64+
from django.template.backends.django import DjangoTemplates # noqa
7165
from django.template.loader import get_template # noqa
7266
from django.test import TestCase # noqa
7367

74-
if django.VERSION >= (1, 8):
75-
from django.template.backends.django import DjangoTemplates # noqa
76-
7768

7869
class DjangoPluginTestCase(StdStreamCapturingMixin, TempDirMixin, TestCase):
7970
"""A base class for all our tests."""
@@ -116,7 +107,7 @@ def run_django_coverage(
116107
str: the text produced by the template.
117108
118109
"""
119-
use_real_context = (django.VERSION < (1, 8))
110+
use_real_context = False
120111

121112
if options is None:
122113
options = {'source': ["."]}
@@ -256,7 +247,7 @@ def squashed(s):
256247
def django_start_at(*needed_version):
257248
"""A decorator for tests to require a minimum version of Django.
258249
259-
@django_start_at(1, 8) # Don't run the test on 1.7 or lower.
250+
@django_start_at(1, 10) # Don't run the test on 1.10 or lower.
260251
def test_thing(self):
261252
...
262253
@@ -267,10 +258,10 @@ def test_thing(self):
267258
return unittest.skip("Django version must be newer")
268259

269260

270-
def django_stop_at(*needed_version):
261+
def django_stop_before(*needed_version):
271262
"""A decorator for tests to require a maximum version of Django.
272263
273-
@django_stop_at(1, 8) # Don't run the test on 1.8 or higher.
264+
@django_stop_before(1, 10) # Don't run the test on 1.10 or higher.
274265
def test_thing(self):
275266
...
276267

tests/test_engines.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33

44
"""Tests of multiple engines for django_coverage_plugin."""
55

6-
from .plugin_test import DjangoPluginTestCase, django_start_at
6+
from .plugin_test import DjangoPluginTestCase
7+
from django.test import modify_settings
78

89

9-
@django_start_at(1, 8)
1010
class MultipleEngineTests(DjangoPluginTestCase):
1111
def setUp(self):
1212
super(MultipleEngineTests, self).setUp()
1313

14-
# Move to module imports once we drop support for Django < 1.7
15-
from django.test import modify_settings
1614
engine = {
1715
'NAME': 'other',
1816
'BACKEND': 'django.template.backends.django.DjangoTemplates',
@@ -38,7 +36,6 @@ def test_string_template(self):
3836
self.assertEqual(text, 'Hello')
3937

4038
def test_third_engine_not_debug(self):
41-
from django.test import modify_settings
4239
engine3 = {
4340
'NAME': 'notdebug',
4441
'BACKEND': 'django.template.backends.django.DjangoTemplates',

tests/test_extends.py

Lines changed: 3 additions & 4 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_start_at, django_stop_at
6+
from .plugin_test import DjangoPluginTestCase, django_stop_before
77

88

99
class BlockTest(DjangoPluginTestCase):
@@ -148,9 +148,8 @@ def test_include(self):
148148
self.assert_analysis([1, 2], name="nested.html")
149149

150150

151-
# {% ssi %} is in earlier Djangos than 1.5, but doesn't trace properly.
152-
@django_start_at(1, 5)
153-
@django_stop_at(1, 10)
151+
# {% ssi %} is in earlier Djangos than 1.9, but doesn't trace properly.
152+
@django_stop_before(1, 10)
154153
class SsiTest(DjangoPluginTestCase):
155154
"""Test {% ssi %}, which does not trace the included file."""
156155

0 commit comments

Comments
 (0)