#24580: Add test for untested condition in admin_list template tag.
--------------------------------------+------------------------------------
Reporter: None | Owner: None
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Adonys Alea Boffill):
* cc: aaboffill@… (added)
Comment:
This ticket seems fixed. There are almost 2 years since this ticket was
created, and Django has continually evolved. For example, the code
fragment shown in the ticket's description has actually some little
changes.
{{{
# if isinstance(f.rel, models.ManyToOneRel): <= old
line...
if isinstance(f.remote_field, models.ManyToOneRel):
field_val = getattr(result, f.name)
if field_val is None:
result_repr = empty_value_display
else:
result_repr = field_val
else:
result_repr = display_for_field(value, f,
empty_value_display)
if isinstance(f, (models.DateField, models.TimeField,
models.ForeignKey)):
row_classes.append('nowrap')
}}}
I analysed the tests where this fragment of code is involved and I've the
following result:
* Admin tests where the condition `if isinstance(f.remote_field,
models.ManyToOneRel)` is used:
||= Test Name =||= Number of Tests =||
|| admin_changelist || 10 ||
|| admin_views || 48 ||
|| admin_widgets || 1 ||
* Admin tests where the condition `if isinstance(f.remote_field,
models.ManyToOneRel)` returns true:
||= Test Name =||= Number of Tests =||
|| admin_changelist || 7 ||
|| admin_views || 13 ||
|| admin_widgets || 1 ||
* Admin tests where the condition `if isinstance(f.remote_field,
models.ManyToOneRel)` returns false:
||= Test Name =||= Number of Tests =||
|| admin_changelist || 10 ||
|| admin_views || 48 ||
|| admin_widgets || 1 ||
This condition `if isinstance(f.remote_field, models.ManyToOneRel)` in
admin_list template tag works good. I think that there are not other
ticket related specifically with that, and the Django admin
`items_for_result` method works fine. Is still necessary create other test
specifically for that condition??
I think that this ticket could be closed as fixed.
--
Ticket URL: <https://code.djangoproject.com/ticket/24580#comment:3>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.0486d6da4b7b6b7029da95dfb6423fa3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.