Friday, July 31, 2020

Pytest, django, and logging formatters


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?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3b41e813-b475-4418-bd90-ea6569ab5523n%40googlegroups.com.

No comments:

Post a Comment