Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 17, 2024
1 parent cf647d0 commit c3fce9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,19 @@ def test_widget_media_applied_cache_suffix(self):
tinymce_version = "6.8"

orig_config = tinymce.settings.DEFAULT_CONFIG
with patch.dict(tinymce.settings.DEFAULT_CONFIG, {**orig_config, "cache_suffix": f"?ver={tinymce_version}"}):
with patch.dict(
tinymce.settings.DEFAULT_CONFIG,
{**orig_config, "cache_suffix": f"?ver={tinymce_version}"},
):
widget = TinyMCE()

self.assertEqual(list(widget.media.render_css()), [])
self.assertEqual(
widget.media.render_js(),
[
f'<script src="/tinymce/compressor/?ver={tinymce_version}"></script>',
f'<script src="/static/django_tinymce/init_tinymce.js?ver={tinymce_version}"></script>'
]
f'<script src="/static/django_tinymce/init_tinymce.js?ver={tinymce_version}"></script>',
],
)

def test_tinymce_widget_required(self):
Expand All @@ -158,7 +161,7 @@ def test_tinymce_widget_allow_translated_options(self):
orig_config = tinymce.settings.DEFAULT_CONFIG
style_formats = [{"title": gettext_lazy("Awesome style"), "inline": "strong"}]
with patch.dict(
tinymce.settings.DEFAULT_CONFIG, {**orig_config, "style_formats": style_formats}
tinymce.settings.DEFAULT_CONFIG, {**orig_config, "style_formats": style_formats}
):
html = widget.render("foobar", "lorem ipsum", attrs={"id": "id_foobar"})
self.assertIn("Awesome style", html)
6 changes: 3 additions & 3 deletions tinymce/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ def _media(self):
media = property(_media)

def _render_js(self):
revision_parameter = tinymce.settings.DEFAULT_CONFIG.get('cache_suffix', '')
revision_parameter = tinymce.settings.DEFAULT_CONFIG.get("cache_suffix", "")

return [
format_html(
'<script src="{}{}"></script>',
(self.absolute_path(path)), revision_parameter)
'<script src="{}{}"></script>', (self.absolute_path(path)), revision_parameter
)
for path in self._js
]

Expand Down

0 comments on commit c3fce9d

Please sign in to comment.