Skip to content

Bug in assert_raise_message #4559

@amueller

Description

@amueller

If the function passed to assert_raise_message raises a different kind of error than expected, this error is not caught, i.e. the original error is raised.
Example

def f():
    raise ValueError("That's how you get ants")
assert_raise_message(TypeError, "wrong type", f)

will raise "ValueError 'That's how you get ants'" when it should raise "AssertionError, f didn't raise TypeError".

On the other hand, assert_raises_regex behaves correctly. So I think instead of fixing the bug, we should just trash "assert_raise_message" and use the standard function instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEasyWell-defined and straightforward way to resolve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions