Skip to content

Assertion rewrite breaks for objects that reimplement __getattr__ #4631

Closed
@AnjoMan

Description

@AnjoMan

Got stuck on this for a bit while I was testing an object I wrote which implemented __getattr__ -- i'd forgotten to raise an AttributeError if I couldn't fetch the given attribute.

If you do an assertion like this with the property access directly in the assertion statement, pytest does a call to object.__name__ to try and make a nicer assertion message, and when my __getattr__ fails the stack trace ends up in the test error message, even though it wasn't the reason for the test to fail.

I've written a test and identified a fix: #4632

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: rewriterelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions