#37064: SimpleTestCase._remove_databases_failures() crashes on un-wrapped
connection methods
-------------------------------------+-------------------------------------
Reporter: Rio Weber | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: 6.0
Severity: Normal | Resolution:
Keywords: testcase, | Triage Stage:
databases, multi-db, regression | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Rio Weber):
Replying to [comment:1 Simon Charette]:
i'm going to wait to keep making PR's,can't update after close.
anyway, I was able to confirm this is a Django bug....
`_remove_databases_failures()` accesses `method.wrapped` on every
"disallowed" connection-method it walks, so the attribute is still the
`_DatabaseFailure` instance that setup installed. So any mutation between
`setUpClass` and `tearDownClass` makes teardown crash with:
{{{
AttributeError: 'function' object has no attribute 'wrapped'
}}}
....…which is unrecoverable, seems like the whole class teardown fails
Notes: Reproduced under stock `python manage.py test` on Django 6.0.3
(`main` [@526b548cfb])
Fix is one line of code:
add `isinstance(method, _DatabaseFailure)` before unwrapping, so teardown
becomes same regardless of intermediate attribute state.
(Happy to share the full trace if useful)
--
Ticket URL: <https://code.djangoproject.com/ticket/37064#comment:4>
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/0107019dc1bb90aa-697f44a3-2541-4fa8-8ddb-d50aafb9bf4b-000000%40eu-central-1.amazonses.com.