From 0b470987ba83cd2b3f5bf2e50847b07084192b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 7 Jul 2022 15:23:03 +0200 Subject: [PATCH] misc: set response.content as bytes, as appropriate (#67137) --- combo/public/views.py | 4 ++-- tests/test_public.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/combo/public/views.py b/combo/public/views.py index 21fe3da7..a6984ec9 100644 --- a/combo/public/views.py +++ b/combo/public/views.py @@ -364,8 +364,8 @@ def skeleton(request): template_name = combo_template['template'] response = render(request, template_name, ctx) - response.content = '{%% with page_template_name="%s" %%}%s{%% endwith %%}' % ( - str(selected_page.template_name), + response.content = b'{%% with page_template_name="%s" %%}%s{%% endwith %%}' % ( + selected_page.template_name.encode(), response.content, ) response['X-Combo-Page-Id'] = str(selected_page.id) diff --git a/tests/test_public.py b/tests/test_public.py index cda84c85..e07a4d81 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -341,7 +341,7 @@ def test_page_skeleton(app): resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net/foo/bar')) assert '{% block placeholder-content %}{% block content %}{% endblock %}{% endblock %}' in resp.text assert '{% block placeholder-footer %}{% block footer %}{% endblock %}{% endblock %}' in resp.text - assert resp.text.startswith('{% with page_template_name="standard" %}') + assert resp.text.startswith('{% with page_template_name="standard" %}\n') # url netloc match resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net'))