Extend approx to complex objects #8902
Labels
topic: approx
Related to pytest.approx function
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
What's the problem this feature will solve?
Approximate equality of complex objects using
pytest.approx
.Apparently, in this toy example, we can simply compare each of the attributes using
pytest.approx
.However, in reality the cases may become more complex, where comparison of the attributes may become fragile (for one objects some attrs were assigned after initialization, while for the others were not).
Describe the solution you'd like
I created a package
approx
to handle complex objects: https://github.com/ivanovmg/approxI suppose that some of its functionality can be adopted by
pytest
if this behavior is desirable.Basically, we loop through all the fields recursively and check if they are approximately equal.
Alternative Solutions
Delegate the responsibility for the approximate object comparisons to a developer of the class.
Additional context
Related issues:
The text was updated successfully, but these errors were encountered: