Django4: TemplateTagTests.test_site_branding_tag test failure in Debian unstable

Bug #1980214 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Akihiro Motoki

Bug Description

Hi,

Building Horizon (yoga) in Debian Unstable resulted in failure with TemplateTagTests.test_site_branding_tag. Here's the build log:

___________________ TemplateTagTests.test_site_branding_tag ____________________
[gw9] linux -- Python 3.9.13 /usr/bin/python3.9

self = <horizon.test.unit.templatetags.test_templatetags.TemplateTagTests testMethod=test_site_branding_tag>

    def test_site_branding_tag(self):
        """Test if site_branding tag renders the correct setting."""
> rendered_str = self.render_template_tag("site_branding", "branding")

horizon/test/unit/templatetags/test_templatetags.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
horizon/test/unit/templatetags/test_templatetags.py:47: in render_template_tag
    return self.render_template(tag_call, tag_require)
horizon/test/unit/templatetags/test_templatetags.py:54: in render_template
    return template.render(Context(context))
/usr/lib/python3/dist-packages/django/template/base.py:175: in render
    return self._render(context)
/usr/lib/python3/dist-packages/django/test/utils.py:111: in instrumented_test_render
    return self.nodelist.render(context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = [<django.template.defaulttags.LoadNode object at 0x7efd84ca8d60>, <TextNode: ' '>, <horizon.templatetags.branding.SiteBrandingNode object at 0x7efd84ca82e0>]
context = [{'True': True, 'False': False, 'None': None}, {}]

    def render(self, context):
> return SafeString("".join([node.render_annotated(context) for node in self]))
E TypeError: sequence item 2: expected str instance, __proxy__ found

Akihiro Motoki (amotoki)
summary: - TemplateTagTests.test_site_branding_tag test failure in Debian unstable
- with Horizon / Yoga
+ Django4: TemplateTagTests.test_site_branding_tag test failure in Debian
+ unstable with Horizon / Yoga
Revision history for this message
Akihiro Motoki (amotoki) wrote : Re: Django4: TemplateTagTests.test_site_branding_tag test failure in Debian unstable with Horizon / Yoga

Perhaps it is specific to Django 4, but no information is not provided in the description.
Could you add more detail info on the environment in Debian unstable so that the upstream can track the issue?

Akihiro Motoki (amotoki)
Changed in horizon:
assignee: nobody → Akihiro Motoki (amotoki)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Akihiro Motoki (amotoki) wrote :

stable/yoga does not support Django 4.0. It can be fixed in the master branch (for Zed release) as a best-effort basis.
If the fix does not break any existing behavior of yoga release, we can potentially accept a backport.
I will take care of it ONLY for the master branch.

If it is about the support version of Django (i.e. Django 3.2 as of yoga release), please let us know.

Revision history for this message
Akihiro Motoki (amotoki) wrote :

I removed "Yoga" from the bug title as Django 4.0 is not a target Django version in horizon yoga release.

summary: Django4: TemplateTagTests.test_site_branding_tag test failure in Debian
- unstable with Horizon / Yoga
+ unstable
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/horizon/+/851262

Changed in horizon:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.opendev.org/c/openstack/horizon/+/851262
Committed: https://opendev.org/openstack/horizon/commit/b893bcdee32a640f148e1682485da849f0058f31
Submitter: "Zuul (22348)"
Branch: master

commit b893bcdee32a640f148e1682485da849f0058f31
Author: Akihiro Motoki <email address hidden>
Date: Thu Jul 28 04:29:58 2022 +0900

    Make site_branding tag work with Django 4.0

    A test for site_branding tag starts to fail with Django 4.0.
    It seems to happen as settings.SITE_BRANDING is _("Horizon") and
    a translation marker _() is no longer evaluated during rendering.

    As a solution, this commit changes the implementation of
    site_branding tag to use "simple_tag" method
    as django.template.Library.simple_tag() [1] seems to handle
    an i18n-ed string properly.

    [1] https://docs.djangoproject.com/en/4.0/howto/custom-template-tags/#simple-tags

    Closes-Bug: #1980214
    Change-Id: I6fdfffbeef2b405da21289d37722e3f068e27fea

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 23.4.0

This issue was fixed in the openstack/horizon 23.4.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.