@@ -1131,7 +1131,7 @@ Test cases
1131
1131
.. versionchanged :: 3.3
1132
1132
Added the *msg * keyword argument when used as a context manager.
1133
1133
1134
- .. method :: assertLogs(logger=None, level=None)
1134
+ .. method :: assertLogs(logger=None, level=None, formatter=None )
1135
1135
1136
1136
A context manager to test that at least one message is logged on
1137
1137
the *logger * or one of its children, with at least the given
@@ -1146,6 +1146,10 @@ Test cases
1146
1146
its string equivalent (for example either ``"ERROR" `` or
1147
1147
:const: `logging.ERROR `). The default is :const: `logging.INFO `.
1148
1148
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
+
1149
1153
The test passes if at least one message emitted inside the ``with ``
1150
1154
block matches the *logger * and *level * conditions, otherwise it fails.
1151
1155
@@ -1173,6 +1177,10 @@ Test cases
1173
1177
1174
1178
.. versionadded :: 3.4
1175
1179
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
+
1176
1184
.. method :: assertNoLogs(logger=None, level=None)
1177
1185
1178
1186
A context manager to test that no messages are logged on
0 commit comments