Skip to content

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

Closed

Description

@skirpichev

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

Linked PRs

Activity

  1. 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[/+] on Jun 2, 2024
  2. vstinner commented on Jun 3, 2024

    @vstinner
    Member

    Do you want to propose a fix?

  3. skirpichev commented on Jun 3, 2024

    @skirpichev
    MemberAuthor

    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.

  4. serhiy-storchaka commented on Jun 4, 2024

    @serhiy-storchaka
    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.

  5. skirpichev commented on Jun 4, 2024

    @skirpichev
    MemberAuthor

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

  6. vstinner commented on Jun 4, 2024

    @vstinner
    Member

    test_exc() can be kept, right.

  7. serhiy-storchaka commented on Jun 4, 2024

    @serhiy-storchaka
    Member

    It should be kept if it is used.

  8. self-assigned this
    on Apr 16, 2025
  9. added a commit that references this issue on Jun 13, 2025
  10. removed their assignment
    on Jun 13, 2025
  11. added a commit that references this issue on May 24, 2026
  12. added a commit that references this issue on Jun 8, 2026
  13. skirpichev commented on Jul 8, 2026

    @skirpichev
    MemberAuthor

    Ah, this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions