Skip to content

Commit 6ae1b5f

Browse files
committed
Also need a decorator for maximum Django version
1 parent 62ffae3 commit 6ae1b5f

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

tests/plugin_test.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,28 @@ def squashed(s):
175175
return re.sub(r"\s", "", s)
176176

177177

178-
def needs_django(*needed_version):
178+
def django_start_at(*needed_version):
179179
"""A decorator for tests to require a minimum version of Django.
180180
181-
@needs_django(1, 8) # Don't run the test on 1.7 or lower.
181+
@django_start_at(1, 8) # Don't run the test on 1.7 or lower.
182182
def test_thing(self):
183183
...
184184
185185
"""
186-
if django.VERSION >= tuple(needed_version):
186+
if django.VERSION >= needed_version:
187187
return lambda func: func
188188
else:
189189
return unittest.skip("Django version must be newer")
190+
191+
def django_stop_at(*needed_version):
192+
"""A decorator for tests to require a maximum version of Django.
193+
194+
@django_stop_at(1, 8) # Don't run the test on 1.8 or higher.
195+
def test_thing(self):
196+
...
197+
198+
"""
199+
if django.VERSION < needed_version:
200+
return lambda func: func
201+
else:
202+
return unittest.skip("Django version must be older")

tests/test_extends.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Tests of template inheritance for django_coverage_plugin."""
22

3-
from .plugin_test import DjangoPluginTestCase, needs_django
3+
from .plugin_test import DjangoPluginTestCase, django_start_at
44

55

66
class BlockTest(DjangoPluginTestCase):
@@ -146,7 +146,7 @@ def test_include(self):
146146

147147

148148
# {% ssi %} is in earlier Djangos than 1.5, but doesn't trace properly.
149-
@needs_django(1, 5)
149+
@django_start_at(1, 5)
150150
class SsiTest(DjangoPluginTestCase):
151151
"""Test {% ssi %}, which does not trace the included file."""
152152

tests/test_simple.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding: utf8
22
"""Simple tests for django_coverage_plugin."""
33

4-
from .plugin_test import DjangoPluginTestCase, needs_django
4+
from .plugin_test import DjangoPluginTestCase, django_start_at
55

66
# TODO: test what happens if TEMPLATE_DEBUG is not set.
77

@@ -154,7 +154,7 @@ def test_firstof(self):
154154
self.assertEqual(text, "B\nB\nquux\n")
155155
self.assert_analysis([1, 2, 3])
156156

157-
@needs_django(1, 8)
157+
@django_start_at(1, 8)
158158
def test_lorem(self):
159159
self.make_template("""\
160160
First
@@ -175,7 +175,7 @@ def test_now(self):
175175
self.assertEqual(text, "Now:\nnow\n.\n")
176176
self.assert_analysis([1, 2, 3])
177177

178-
@needs_django(1, 8)
178+
@django_start_at(1, 8)
179179
def test_now_as(self):
180180
self.make_template("""\
181181
{% now "\\n\\o\\w" as right_now %}
@@ -195,7 +195,7 @@ def test_templatetag(self):
195195
self.assertEqual(text, "{%\nurl 'entry_list'\n%}\n")
196196
self.assert_analysis([1, 2, 3])
197197

198-
@needs_django(1, 5) # 1.4 had different syntax for {% url %}
198+
@django_start_at(1, 5) # 1.4 had different syntax for {% url %}
199199
def test_url(self):
200200
self.make_template("""\
201201
{% url 'index' %}
@@ -205,7 +205,7 @@ def test_url(self):
205205
self.assertEqual(text, "/home\nnice.\n")
206206
self.assert_analysis([1, 2])
207207

208-
@needs_django(1, 5) # {% verbatim %} is new in 1.5
208+
@django_start_at(1, 5) # {% verbatim %} is new in 1.5
209209
def test_verbatim(self):
210210
self.make_template("""\
211211
1

0 commit comments

Comments
 (0)