Skip to content

test_exc() helper in test_format.py doesn't fail if exception message unexpected #119949

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

Open
skirpichev opened this issue Jun 2, 2024 · 6 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@skirpichev
Copy link
Contributor

skirpichev commented Jun 2, 2024

Bug report

Bug description:

Follow up of #119780. Quick fix is to add raise statement: 7f9b4d0 But it was suggested to do refactoring of this function instead.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

@skirpichev skirpichev added the type-bug An unexpected behavior, bug, or error label Jun 2, 2024
@skirpichev skirpichev changed the title test_exc() helper in test_format.py doesn't fail if exception messages unexpected test_exc() helper in test_format.py doesn't fail if exception message unexpected Jun 2, 2024
@sobolevn sobolevn added the tests Tests in the Lib/test dir label Jun 3, 2024
@vstinner
Copy link
Member

vstinner commented Jun 3, 2024

Do you want to propose a fix?

@skirpichev
Copy link
Contributor Author

First, I think that raise statement from mentioned PR was a right quick fix. Code seems quite old (9f8ad3f) and that part could be easily backported.

@serhiy-storchaka
Copy link
Member

We should use standard TestCase methods assertRaises()/assertRaisesRegex() to handle expected errors and subTest() to add more context and allow multiple failures per test.

@skirpichev
Copy link
Contributor Author

Should we keep old helper interfaces, i.e. test_exc()?

@vstinner
Copy link
Member

vstinner commented Jun 4, 2024

test_exc() can be kept, right.

@serhiy-storchaka
Copy link
Member

It should be kept if it is used.

@skirpichev skirpichev self-assigned this Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants