Opened 3 months ago

Closed 3 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 Simon Charette, 3 months ago

Triage Stage: UnreviewedAccepted

Thanks Adam, patch LGTM as well.

comment:2 by Sarah Boyce, 3 months ago

Needs tests: set

comment:3 by Adam Johnson, 3 months ago

Needs tests: unset

comment:4 by Sarah Boyce, 3 months ago

Triage Stage: AcceptedReady for checkin

comment:5 by Sarah Boyce <42296566+sarahboyce@…>, 3 months ago

In 9a3f3b84:

Refs #36435 -- Tidied tests for CaptureQueriesContext and assertNumQueries.

Avoided repeatedly templating the URL and hoisted Person creation to
setUpTestData in AssertNumQueriesContextManagerTests to repeat the same
pattern as in CaptureQueriesContextManagerTests.

comment:6 by Sarah Boyce <42296566+sarahboyce@…>, 3 months ago

Resolution: fixed
Status: assignedclosed

In f0a87895:

Fixed #36435 -- Made CaptureQueriesContext restore reset_queries conditionally.

Note: See TracTickets for help on using tickets.
Back to Top