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
1111 of the current version to prevent error while importing. Thank to @vmsp
1212* Context in django.template.base is removed from Django and
1313 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
1416
15172.0.4
1618======
Original file line number Diff line number Diff line change 22
33from io import BytesIO
44
5- import django
5+ from django import get_version as django_version
66
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'
88
99if _CACHED_STATIC_FILES_STORAGE_AVAILABLE :
1010 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
12from django .forms import Media
23from django .test import TestCase
34
@@ -147,6 +148,7 @@ class MyMedia(PipelineFormMedia):
147148 js = ('extra1.js' , 'extra2.js' )
148149
149150 media = Media (MyMedia )
151+ script_tag = '<script type="text/javascript" src="%s"></script>' if django_version () < '3.1' else '<script src="%s"></script>'
150152
151153 self .assertEqual (
152154 MyMedia .js ,
@@ -160,7 +162,7 @@ class MyMedia(PipelineFormMedia):
160162 self .assertEqual (
161163 media .render_js (),
162164 [
163- '<script type="text/javascript" src="%s"></script>' % path
165+ script_tag % path
164166 for path in (
165167 '/static/extra1.js' ,
166168 '/static/extra2.js' ,
@@ -177,6 +179,7 @@ class MyMedia(PipelineFormMedia):
177179 js = ('extra1.js' , 'extra2.js' )
178180
179181 media = Media (MyMedia )
182+ script_tag = '<script type="text/javascript" src="%s"></script>' if django_version () < '3.1' else '<script src="%s"></script>'
180183
181184 self .assertEqual (
182185 MyMedia .js ,
@@ -191,7 +194,7 @@ class MyMedia(PipelineFormMedia):
191194 self .assertEqual (
192195 media .render_js (),
193196 [
194- '<script type="text/javascript" src="%s"></script>' % path
197+ script_tag % path
195198 for path in (
196199 '/static/extra1.js' ,
197200 '/static/extra2.js' ,
You can’t perform that action at this time.
0 commit comments