#37310: MediaAsset instances with attributes should not compare equal to strings
-------------------------------------+-------------------------------------
Reporter: miladkhoshdel | Owner:
| miladkhoshdel
Type: Bug | Status: assigned
Component: Forms | Version: 6.1
Severity: Release blocker | Resolution:
Keywords: MediaAsset hash | Triage Stage: Accepted
equality |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by miladkhoshdel):
Thanks, that makes sense. The failing assertions currently rely on this
comparison:
{{{
Stylesheet("a.css", media="screen") == "a.css"
}}}
This is currently `True`, even though `_css_lists` contains a `Stylesheet`
instance rather than a string. With the proposed change, it becomes
`False`, so the expected value should use the normalized object:
{{{
{"screen": [Stylesheet("a.css", media="screen")]}
}}}
The functional change is the intended one: assets with attributes no
longer compare equal to plain strings. Regular media merging and rendering
remain unchanged because ordinary string paths are normalized into
`Script` or `Stylesheet` instances before merging.
After updating these assertions, the full Forms test suite passes. I’ll
revise the patch accordingly and reopen the PR.
--
Ticket URL: <
https://code.djangoproject.com/ticket/37310#comment:8>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.