#36435: CaptureQueriesContext can miss queries after nesting
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: Bug | Status: assigned
Component: Testing | Version: dev
framework |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
`CaptureQueriesContext.__exit__()`, as used by `assertNumQueries()`,
unconditionally restores the `reset_queries` signal receiver. This
behaviour can lead to missed queries when the context manager is nested
and a request is made after the inner context manager exits.
The solution is to restore the signal receiver in `__exit__()` only if it
was removed in `__enter__()`.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36435>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.