#36942: SimpleTestCase._remove_databases_failures() is not idempotent and
crashes
on complex MRO.
---------------------------------------------+-----------------------------
Reporter: Michele0303 | Owner: michele0303
Type: Bug | Status: assigned
Component: Testing framework | Version: 6.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+-----------------------------
When using complex test inheritance (e.g., mixing multiple
LiveServerTestCase subclasses or dynamic test class generation), the
cleanup method
{{{_remove_databases_failures}}} can be called in a state where database
connection methods have already been unwrapped or were never wrapped for a
specific alias.
Currently, the code assumes the wrapped attribute always exists:
{{{setattr(connection, name, method.wrapped)}}}
This leads to an {{{AttributeError: 'function' object has no attribute
'wrapped'.}}}
The proposed fix adds a defensive {{{hasattr(method, "wrapped")}}} check
to make the teardown process idempotent and robust against complex class
hierarchies.
--
Ticket URL: <https://code.djangoproject.com/ticket/36942>
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/0107019c8c9da59c-693631f2-7d1c-46de-8a29-77d48e751dda-000000%40eu-central-1.amazonses.com.