Skip to content

Commit 05380c1

Browse files
committed
fix: remove more older django version compat
1 parent 68513d4 commit 05380c1

File tree

3 files changed

+3
-65
lines changed

3 files changed

+3
-65
lines changed

pipeline/conf.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import shlex
77

88
from django.conf import settings as _settings
9-
try:
10-
from django.core.signals import setting_changed
11-
except ImportError:
12-
# Django < 1.8
13-
from django.test.signals import setting_changed
9+
from django.core.signals import setting_changed
1410
from django.dispatch import receiver
1511
from django.utils.six import string_types
1612

tests/tests/test_storage.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
from django.test import TestCase
77
from django.test.utils import override_settings
88

9-
try:
10-
from django.test.utils import modify_settings
11-
except ImportError:
12-
# Django < 1.7
13-
from tests.utils import modify_settings
9+
from django.test.utils import modify_settings
1410

1511
from pipeline.collector import default_collector
1612
from pipeline.storage import PipelineStorage

tests/utils.py

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import os
22

33
import django
4-
from django.conf import settings
5-
from django.utils import six
64

7-
try:
8-
from django.test import override_settings
9-
except ImportError:
10-
# Django < 1.7
11-
from django.test.utils import override_settings
5+
from django.test import override_settings
126

137

148
def _(path):
@@ -24,51 +18,3 @@ def __init__(self, **kwargs):
2418
# so we must do the same.
2519
super(pipeline_settings, self).__init__()
2620
self.options = {'PIPELINE': kwargs}
27-
28-
29-
# Django < 1.7 (copy-pasted from Django 1.7)
30-
class modify_settings(override_settings):
31-
"""
32-
Like override_settings, but makes it possible to append, prepend or remove
33-
items instead of redefining the entire list.
34-
"""
35-
def __init__(self, *args, **kwargs):
36-
if args:
37-
# Hack used when instantiating from SimpleTestCase._pre_setup.
38-
assert not kwargs
39-
self.operations = args[0]
40-
else:
41-
assert not args
42-
self.operations = list(kwargs.items())
43-
44-
def save_options(self, test_func):
45-
if test_func._modified_settings is None:
46-
test_func._modified_settings = self.operations
47-
else:
48-
# Duplicate list to prevent subclasses from altering their parent.
49-
test_func._modified_settings = list(
50-
test_func._modified_settings) + self.operations
51-
52-
def enable(self):
53-
self.options = {}
54-
for name, operations in self.operations:
55-
try:
56-
# When called from SimpleTestCase._pre_setup, values may be
57-
# overridden several times; cumulate changes.
58-
value = self.options[name]
59-
except KeyError:
60-
value = list(getattr(settings, name, []))
61-
for action, items in operations.items():
62-
# items my be a single value or an iterable.
63-
if isinstance(items, six.string_types):
64-
items = [items]
65-
if action == 'append':
66-
value = value + [item for item in items if item not in value]
67-
elif action == 'prepend':
68-
value = [item for item in items if item not in value] + value
69-
elif action == 'remove':
70-
value = [item for item in value if item not in items]
71-
else:
72-
raise ValueError("Unsupported action: %s" % action)
73-
self.options[name] = value
74-
super(modify_settings, self).enable()

0 commit comments

Comments
 (0)