Skip to content

gh-119949: refactor test_exc() helper in test_format.py#135452

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
skirpichev:refactor-test_exc/119949
May 24, 2026
Merged

gh-119949: refactor test_exc() helper in test_format.py#135452
serhiy-storchaka merged 3 commits into
python:mainfrom
skirpichev:refactor-test_exc/119949

Conversation

@skirpichev
Copy link
Copy Markdown
Member

@skirpichev skirpichev commented Jun 13, 2025

@skirpichev
Copy link
Copy Markdown
Member Author

CC @serhiy-storchaka

@skirpichev
Copy link
Copy Markdown
Member Author

CC @JelleZijlstra, It's a follow-up of pr #119781

@skirpichev skirpichev closed this Feb 4, 2026
@skirpichev skirpichev deleted the refactor-test_exc/119949 branch February 4, 2026 12:03
@serhiy-storchaka
Copy link
Copy Markdown
Member

To minimize the diff, you can add methods, and then use local variables as aliases.

def _test_exc(self, formatstr, args, exception, excmsg):
    ...

def test_something(self):
    test_exc = self._test_exc
    ...

@skirpichev skirpichev restored the refactor-test_exc/119949 branch May 23, 2026 07:35
@skirpichev skirpichev reopened this May 23, 2026
@skirpichev skirpichev self-assigned this May 23, 2026
@skirpichev skirpichev marked this pull request as draft May 23, 2026 07:41
@skirpichev skirpichev removed their assignment May 24, 2026
@skirpichev skirpichev marked this pull request as ready for review May 24, 2026 08:34
@skirpichev
Copy link
Copy Markdown
Member Author

To minimize the diff, you can add methods, and then use local variables as aliases.

Done. Unfortunately, some tests still should be changed due to using assertRaisesRegex instead of string comparison.

Copy link
Copy Markdown
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.

You can use re.escape() to minimize the diff.

Copy link
Copy Markdown
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.

LGTM. 👍

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) May 24, 2026 10:03
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 24, 2026
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label May 24, 2026
@serhiy-storchaka serhiy-storchaka merged commit 0851700 into python:main May 24, 2026
57 checks passed
@miss-islington-app
Copy link
Copy Markdown

Thanks @skirpichev for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app
Copy link
Copy Markdown

Sorry, @skirpichev and @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 0851700a9d99ca4bebd8d5f9d73c8c9ab1084405 3.14

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 24, 2026

GH-150329 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 24, 2026
@skirpichev skirpichev deleted the refactor-test_exc/119949 branch May 24, 2026 11:12
@skirpichev
Copy link
Copy Markdown
Member Author

@serhiy-storchaka, I think it doesn't make sense to backport this for 3.14 as #142081 wasn't backported.

@serhiy-storchaka serhiy-storchaka removed the needs backport to 3.14 bugs and security fixes label May 24, 2026
@serhiy-storchaka serhiy-storchaka removed their assignment May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants