Skip to content

Commit 7881c64

Browse files
committed
Updates unittest docs
1 parent 6009858 commit 7881c64

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Doc/library/unittest.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ Test cases
11311131
.. versionchanged:: 3.3
11321132
Added the *msg* keyword argument when used as a context manager.
11331133

1134-
.. method:: assertLogs(logger=None, level=None)
1134+
.. method:: assertLogs(logger=None, level=None, formatter=None)
11351135

11361136
A context manager to test that at least one message is logged on
11371137
the *logger* or one of its children, with at least the given
@@ -1146,6 +1146,10 @@ Test cases
11461146
its string equivalent (for example either ``"ERROR"`` or
11471147
:const:`logging.ERROR`). The default is :const:`logging.INFO`.
11481148

1149+
If given, *formatter* should be a :class:`logging.Formatter` object.
1150+
The default is a formatter with
1151+
``LOGGING_FORMAT = "%(levelname)s:%(name)s:%(message)s"``
1152+
11491153
The test passes if at least one message emitted inside the ``with``
11501154
block matches the *logger* and *level* conditions, otherwise it fails.
11511155

@@ -1173,6 +1177,10 @@ Test cases
11731177

11741178
.. versionadded:: 3.4
11751179

1180+
.. versionchanged:: 3.15
1181+
Now accepts a formatter argument so your assertions can match
1182+
a custom format where you are using one.
1183+
11761184
.. method:: assertNoLogs(logger=None, level=None)
11771185

11781186
A context manager to test that no messages are logged on

0 commit comments

Comments
 (0)