-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
1. Problem
The following code
class A:
def __iter__(self):
raise ValueError()
def __eq__(self, o: object) -> bool:
return self is o
def test_a():
assert A() == A()
...will throw:
def test_a():
> assert A() == A()
E assert <tests.test_p...0019C132F1490> == <tests.test_p...0019C132F12B0>
E (pytest_assertion plugin: representation of details failed: XXX\test_pp.py:3: ValueError.
E Probably an object has a faulty __repr__.)
...because __iter__
is called in order to repr()
the object?
Is there a way to avoid __iter__
being called when a test fails?
2. Setup
Python 3.8.2 | pytest 6.1.1
wmayner
Metadata
Metadata
Assignees
Labels
topic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressedproblem that needs to be addressed