Opened 25 hours ago

Last modified 25 hours ago

#36038 assigned Cleanup/optimization

Added a test case for the display_for_field function when a FileField is passed.

Reported by: Antoliny Owned by: Antoliny
Component: Utilities Version: 5.1
Severity: Normal Keywords: display_for_field, FileFIeld
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Antoliny)

def display_for_field(value, field, empty_value_display):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon
    ...
    elif isinstance(field, (models.IntegerField, models.FloatField)):
        return formats.number_format(value)
    elif isinstance(field, models.FileField) and value:
        return format_html('<a href="{}">{}</a>', value.url, value)
    ...

There is no test case for the display_for_field function when a FileField object is passed. --> admin_utils test code

When the FileField handling was added in the above function, I found that the test was conducted indirectly through the FileWidget readonly attribute. --> test code

However, I believe it would be better to have a direct test case for when a FileField is passed, considering that display_for_field function is globally accessible.

Change History (3)

comment:1 by Antoliny, 25 hours ago

Owner: set to Antoliny

comment:2 by Antoliny, 25 hours ago

Description: modified (diff)

comment:3 by Antoliny, 25 hours ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top