gh-134567: Exposes log format to users in unittest.TestCase.assertLogs by garry-cairns · Pull Request #134570 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
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

Conversation

garry-cairns
Copy link
Contributor

@garry-cairns garry-cairns commented May 23, 2025

Allows users optionally to pass a custom log formatter to assertLogs such that assertions match expected custom formats where they are used. Existing behavior should be unaffected.

@python-cla-bot
Copy link

python-cla-bot bot commented May 23, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented May 23, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@garry-cairns
Copy link
Contributor Author

@ezio-melotti @rbtcollins @gpshead @serhiy-storchaka Does anyone have any bandwidth to look a this one? I believe it will be a fairly quick either accept or reject type change.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a new feature, it needs a documentation. Add a versionchanged directive for assertLogs(), add an entry in the What's New document.

I have no strong opinion about this feature.

@serhiy-storchaka serhiy-storchaka requested a review from pitrou June 23, 2025 20:03
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"so your assertions can match a custom format" looks misleading. It can be misinterpreted as if assertLogs() itself checks that logging messages were formatted using the specified formatter. This is not true. assertLogs() does not check what formatter was used for the specified logger. It uses the specified formatter (or the default one) to format logging messages in output.

I suggest simply saying that a formatter is used to format the strings in output.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update also What's New and the versionchanged directive.

@garry-cairns
Copy link
Contributor Author

Please update also What's New and the versionchanged directive.

Can you clarify what's outstanding here? I thought I had addressed these with the previous commit.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They still contain "so your assertions can match". You only changed the NEWS entry.

@garry-cairns
Copy link
Contributor Author

They still contain "so your assertions can match". You only changed the NEWS entry.

Ah got you, should be sorted now. Thanks for all your help and attention on this.

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jul 2, 2025

LGTM. 👍

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 2, 2025 09:40
@serhiy-storchaka serhiy-storchaka merged commit 51ab66b into python:main Jul 2, 2025
44 checks passed
@garry-cairns garry-cairns deleted the fix-issue-134567 branch July 2, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.