Opened 3 years ago

Closed 13 months ago

#17958 closed New feature (duplicate)

Add a capture_logging test util

Reported by: claudep 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 claudep 3 years ago.
Add context manager for logging capture

Download all attachments as: .zip

Change History (6)

Changed 3 years ago by claudep

Add context manager for logging capture

comment:1 Changed 3 years ago by claudep

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

comment:2 Changed 3 years ago by ptone

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by ptone

#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 13 months ago by timo

  • 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 13 months ago by claudep

  • Resolution set to duplicate
  • Status changed from new to closed

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