Skip to content

Commit d1c443a

Browse files
committed
refactor: remove code we only needed on django<5
1 parent 4eb4fc9 commit d1c443a

3 files changed

Lines changed: 3 additions & 68 deletions

File tree

django_coverage_plugin/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def check_debug():
6969
return True
7070

7171

72-
if django.VERSION < (3, 0):
73-
raise RuntimeError("Django Coverage Plugin requires Django 3.x or higher")
72+
if django.VERSION < (5, 0):
73+
raise RuntimeError("Django Coverage Plugin requires Django 5.x or higher")
7474

7575

7676
# Since we are grabbing at internal details, we have to adapt as they

tests/plugin_test.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os
88
import os.path
99
import re
10-
import unittest
1110

1211
import coverage
1312
import django
@@ -279,34 +278,6 @@ def squashed(s):
279278
return re.sub(r"\s", "", s)
280279

281280

282-
def django_start_at(*needed_version):
283-
"""A decorator for tests to require a minimum version of Django.
284-
285-
@django_start_at(1, 10) # Don't run the test on 1.10 or lower.
286-
def test_thing(self):
287-
...
288-
289-
"""
290-
if django.VERSION >= needed_version:
291-
return lambda func: func
292-
else:
293-
return unittest.skip("Django version must be newer")
294-
295-
296-
def django_stop_before(*needed_version):
297-
"""A decorator for tests to require a maximum version of Django.
298-
299-
@django_stop_before(1, 10) # Don't run the test on 1.10 or higher.
300-
def test_thing(self):
301-
...
302-
303-
"""
304-
if django.VERSION < needed_version:
305-
return lambda func: func
306-
else:
307-
return unittest.skip("Django version must be older")
308-
309-
310281
class PluginDisabled(Exception):
311282
"""Raised if we find that our plugin has been disabled."""
312283
pass

tests/test_flow.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import textwrap
77

8-
from .plugin_test import DjangoPluginTestCase, django_stop_before, squashed
8+
from .plugin_test import DjangoPluginTestCase, squashed
99

1010

1111
class IfTest(DjangoPluginTestCase):
@@ -207,39 +207,3 @@ def test_ifchanged_variable(self):
207207
})
208208
self.assertEqual(squashed(text), 'AXYBZW')
209209
self.assert_analysis([1, 2, 3, 5])
210-
211-
212-
@django_stop_before(4, 0)
213-
class IfEqualTest(DjangoPluginTestCase):
214-
215-
def test_ifequal(self):
216-
self.make_template("""\
217-
{% for i,x in items %}
218-
{% ifequal x "X" %}
219-
X
220-
{% endifequal %}
221-
{{ i }}
222-
{% endfor %}
223-
""")
224-
225-
text = self.run_django_coverage(context={
226-
'items': [(0, 'A'), (1, 'X'), (2, 'X'), (3, 'B')],
227-
})
228-
self.assertEqual(squashed(text), '0X1X23')
229-
self.assert_analysis([1, 2, 3, 5])
230-
231-
def test_ifnotequal(self):
232-
self.make_template("""\
233-
{% for i,x in items %}
234-
{% ifnotequal x "X" %}
235-
X
236-
{% endifnotequal %}
237-
{{ i }}
238-
{% endfor %}
239-
""")
240-
241-
text = self.run_django_coverage(context={
242-
'items': [(0, 'A'), (1, 'X'), (2, 'X'), (3, 'B')],
243-
})
244-
self.assertEqual(squashed(text), 'X012X3')
245-
self.assert_analysis([1, 2, 3, 5])

0 commit comments

Comments
 (0)