#36942: SimpleTestCase._remove_databases_failures() is not idempotent and 
crashes
on complex MRO.
-----------------------------------+---------------------------------------
     Reporter:  Michele Fiori      |                    Owner:  michele0303
         Type:  Bug                |                   Status:  assigned
    Component:  Testing framework  |                  Version:  6.0
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+---------------------------------------
Description changed by Michele Fiori:

Old description:

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

New description:

 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.

 PR: https://github.com/django/django/pull/20758

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36942#comment:1>
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/0107019c8cb184be-94c58d25-86d1-4187-b436-6423b3b9c901-000000%40eu-central-1.amazonses.com.

Reply via email to