#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.