Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow unordered sequences in pytest.approx #9709

Merged
merged 2 commits into from Feb 24, 2022

Conversation

nicoddemus
Copy link
Member

Fix #9692

@@ -708,12 +717,19 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
expected = _as_numpy_array(expected)
cls = ApproxNumpy
elif (
isinstance(expected, Iterable)
hasattr(expected, "__getitem__")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately Sequence requires many other methods (such as __reversible__, __contains__), which would break the previous assumption made by test_generic_ordered_sequence.

@nicoddemus nicoddemus merged commit 5f3d94c into pytest-dev:main Feb 24, 2022
@nicoddemus nicoddemus deleted the 9692-sets-approx branch February 24, 2022 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Current implementation of pytest.approx() cannot be used to compare sets
2 participants