Opened 2 years ago

Closed 5 weeks 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


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 2 years ago.
Add context manager for logging capture

Download all attachments as: .zip

Change History (6)

Changed 2 years ago by claudep

Add context manager for logging capture

comment:1 Changed 2 years ago by claudep

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

comment:2 Changed 2 years ago by ptone

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 14 months 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 5 weeks 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 5 weeks 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.