#36038: Added a test case for the display_for_field function when a FileField is
passed.
-------------------------------------+-------------------------------------
               Reporter:  Antoliny   |          Owner:  (none)
                   Type:             |         Status:  assigned
  Cleanup/optimization               |
              Component:  Utilities  |        Version:  5.1
               Severity:  Normal     |       Keywords:  display_for_field,
           Triage Stage:             |  FileFIeld
  Unreviewed                         |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 {{{
 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. -->
 [https://github.com/django/django/blob/main/tests/admin_utils/tests.py
 admin_utils test code]

 When the `FileField` handling was added in the above function, I found
 that the test was conducted indirectly through the ModelAdmin
 readonly_fields attribute. -->
 [https://github.com/django/django/blob/main/tests/admin_widgets/tests.py#L654
 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.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36038>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070193fe0c280a-31855571-716b-41c2-82a9-183e83e17a17-000000%40eu-central-1.amazonses.com.

Reply via email to