Pytest, django, and logging formatters

13 views
Skip to first unread message

Stephan Stachurski

unread,
Jul 31, 2020, 9:53:24 AM7/31/20
to Django users

I am trying to test a django application that depends on a custom log formatter.

App log lines look like this:

`logger.info("Message with formatting {} {}", "foo", "boo")`

Obviously these log lines depend on a formatter that does something like this:

`msg = msg.format(*self.args)`

The app uses a LOGGING config like this:

LOGGING = {
    'formatters': {
        'standard': {
            '()': 'common.utils.logging_utils.TimeZoneFormatter',

How can I get pytest to set up the same logging configuration while the app is under test?
Reply all
Reply to author
Forward
0 new messages