File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ History
11
11
of the current version to prevent error while importing. Thank to @vmsp
12
12
* Context in django.template.base is removed from Django and
13
13
not used anymore in django-pipeline.
14
+ * Fixing widgets tests of django-pipeline due to Media.render_js change in
15
+ Django. More information in Django ticket #31892
14
16
15
17
2.0.4
16
18
======
Original file line number Diff line number Diff line change 2
2
3
3
from io import BytesIO
4
4
5
- import django
5
+ from django import get_version as django_version
6
6
7
- _CACHED_STATIC_FILES_STORAGE_AVAILABLE = django . VERSION [ 0 ] <= 3 and django . VERSION [ 1 ] < 1
7
+ _CACHED_STATIC_FILES_STORAGE_AVAILABLE = django_version () < '3.1'
8
8
9
9
if _CACHED_STATIC_FILES_STORAGE_AVAILABLE :
10
10
from django .contrib .staticfiles .storage import CachedStaticFilesStorage
Original file line number Diff line number Diff line change
1
+ from django import get_version as django_version
1
2
from django .forms import Media
2
3
from django .test import TestCase
3
4
@@ -147,6 +148,7 @@ class MyMedia(PipelineFormMedia):
147
148
js = ('extra1.js' , 'extra2.js' )
148
149
149
150
media = Media (MyMedia )
151
+ script_tag = '<script type="text/javascript" src="%s"></script>' if django_version () < '3.1' else '<script src="%s"></script>'
150
152
151
153
self .assertEqual (
152
154
MyMedia .js ,
@@ -160,7 +162,7 @@ class MyMedia(PipelineFormMedia):
160
162
self .assertEqual (
161
163
media .render_js (),
162
164
[
163
- '<script type="text/javascript" src="%s"></script>' % path
165
+ script_tag % path
164
166
for path in (
165
167
'/static/extra1.js' ,
166
168
'/static/extra2.js' ,
@@ -177,6 +179,7 @@ class MyMedia(PipelineFormMedia):
177
179
js = ('extra1.js' , 'extra2.js' )
178
180
179
181
media = Media (MyMedia )
182
+ script_tag = '<script type="text/javascript" src="%s"></script>' if django_version () < '3.1' else '<script src="%s"></script>'
180
183
181
184
self .assertEqual (
182
185
MyMedia .js ,
@@ -191,7 +194,7 @@ class MyMedia(PipelineFormMedia):
191
194
self .assertEqual (
192
195
media .render_js (),
193
196
[
194
- '<script type="text/javascript" src="%s"></script>' % path
197
+ script_tag % path
195
198
for path in (
196
199
'/static/extra1.js' ,
197
200
'/static/extra2.js' ,
You can’t perform that action at this time.
0 commit comments