Opened 5 months ago
Closed 5 months ago
#36435 closed Bug (fixed)
CaptureQueriesContext can miss queries after nesting
| Reported by: | Adam Johnson | Owned by: | Adam Johnson |
|---|---|---|---|
| Component: | Testing framework | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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__().
Change History (6)
comment:1 by , 5 months ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 5 months ago
| Needs tests: | set |
|---|
comment:3 by , 5 months ago
| Needs tests: | unset |
|---|
comment:4 by , 5 months ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Note:
See TracTickets
for help on using tickets.
Thanks Adam, patch LGTM as well.