8000 gh-134567: Exposes log format to users in unittest.TestCase.assertLogs by garry-cairns · Pull Request #134570 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-134567: Exposes log format to users in unittest.TestCase.assertLogs #134570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolves review comments from pr 134570
  • Loading branch information
garry-cairns committed Jun 25, 2025
commit ec353d244df93951f71078ce54331c5461f5efed
4 changes: 2 additions & 2 deletions Doc/library/unittest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ Test cases

If given, *formatter* should be a :class:`logging.Formatter` object.
The default is a formatter with
``LOGGING_FORMAT = "%(levelname)s:%(name)s:%(message)s"``
``"%(levelname)s:%(name)s:%(message)s"``

The test passes if at least one message emitted inside the ``with``
block matches the *logger* and *level* conditions, otherwise it fails.
Expand Down Expand Up @@ -1177,7 +1177,7 @@ Test cases

.. versionadded:: 3.4

.. versionchanged:: 3.15
.. versionchanged:: next
Now accepts a formatter argument so your assertions can match
a custom format where you are using one.

Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ typing

unittest
--------
* Expose log formatter to users in TestCase.assertLogs.

* Lets users specify formatter in TestCase.assertLogs.
:func:`unittest.TestCase.assertLogs` will now accept a formatter
argument so your assertions can match a custom format where you are using one.
(Contributed by Garry Cairns in :gh:`134567`.)
Expand Down
Loading
0