Opened 5 years ago

Closed 2 years ago

#17958 closed New feature (duplicate)

Add a capture_logging test util

Reported by: Claude Paroz Owned by: nobody
Component: Testing framework Version: master
Severity: Normal Keywords: logging
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

While working on silencing contrib.gis tests (to-be-created ticket), I find myself in need of a utility to capture logging during tests. This is the result this work.

Attachments (1)

capture_logging.diff (3.8 KB) - added by Claude Paroz 5 years ago.
Add context manager for logging capture

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by Claude Paroz

Attachment: capture_logging.diff added

Add context manager for logging capture

comment:1 Changed 5 years ago by Claude Paroz

to-be-created ticket is #17959 (which represents a real use case for this ticket).

comment:2 Changed 5 years ago by Preston Holmes

Triage Stage: UnreviewedAccepted

comment:3 Changed 3 years ago by Preston Holmes

#19866 added a similar utility, but differs from this patch in several ways, one it was added as private API, not documented for use in other's tests. Second it took the approach close to mocking the logger via monkey-patch of a specific level method, rather than adding a stream to the logging machinery.

This should stay open as it has a different scope of packaging this sort of utility for public use - not something I feel strongly that Django needs to ship publicly, but not something I'm against either.

comment:4 Changed 2 years ago by Tim Graham

Patch needs improvement: set

We resolved the linked ticket without this -- do we still want/need it?

In any case, I'm sure it needs to be updated to apply cleanly.

comment:5 Changed 2 years ago by Claude Paroz

Resolution: duplicate
Status: newclosed

Let's forget it for now. We'll see in the future if there is still some demand for it.

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