This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make LOGGING_FORMAT of assertLogs configurable
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, ezio.melotti, michael.foord, rbcollins
Priority: normal Keywords:

Created on 2015-05-14 12:03 by berker.peksag, last changed 2022-04-11 14:58 by admin.

Messages (4)
msg243182 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-05-14 12:03
It would be useful if we could change the logging format of assertLogs when we use it:

    with self.assertLogs('foo', level='INFO', format='%(message)s') as cm:
        logging.getLogger('foo').info('first message')

    self.assertEqual(cm.output, ['first message'])

Or maybe with a class attribute like maxDiff:

    logFormat = '%(message)s'
msg249032 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-08-23 23:51
Parameters please, TestCase has nothing to do with this - it really shouldn't even have the method.
msg249042 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2015-08-24 08:54
assertLogs is on a Python test suite helper, not TestCase itself.
msg249043 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-08-24 09:09
I don't know if or when it was moved, but right now:

./python -m pydoc unittest.case.TestCase.assertLogs
... the docs for it.
History
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68381
2015-08-24 09:09:43rbcollinssetmessages: + msg249043
2015-08-24 08:54:59michael.foordsetmessages: + msg249042
2015-08-23 23:51:50rbcollinssetmessages: + msg249032
2015-05-14 12:03:49berker.peksagcreate