Skip to content

assert.ok() throwing AssertionError instead of provided Error object #50780

Closed
@piranna

Description

@piranna

Version

v20.9.0

Platform

Linux executive 6.5.0-10-generic #10-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 13 13:49:38 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

assert

What steps will reproduce the bug?

assert.ok() docs says:

If the message parameter is an instance of an Error then it will be thrown instead of the AssertionError.

I've called to it with an Error instance as second argument, and instead of being thrown that error, it's being thrown an AssertionError with it's message field set to the message field of the provided error.

Not sure what's the correct solution here, based on docs and common sense, the provided error should be thrown, but based on homogeneity, an AssertionError should be thrown (current behaviour) so it always throw an AssertionError no matter what it's provided as second argument...

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

Not sure if it's a bug, or a documentation issue.

What do you see instead?

AssertionError is thrown, with provided Error message.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertIssues and PRs related to the assert subsystem.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions