We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
pytest.approx
self.assertAlmostEqual
The replacement for self.assertAlmostEqual(3, 3.0) is round(abs(3 - 3.0), 7) == 0.
self.assertAlmostEqual(3, 3.0)
round(abs(3 - 3.0), 7) == 0
How about replacing it with pytest.approx(3) == 3.0 instead? [pytest docs]
pytest.approx(3) == 3.0
The text was updated successfully, but these errors were encountered:
One big advantage of pytest.appox is that it correctly handles iterables like lists and tuples. Example:
pytest.appox
xy = (1.0, 2.0) assert round(abs(xy - (1, 2)), 7) == 0
fails with
TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
whereas
xy = (1.0, 2.0) assert pytest.approx(xy) == (1, 2)
passes.
Sorry, something went wrong.
fixes.AlmostOp
Successfully merging a pull request may close this issue.
The replacement for
self.assertAlmostEqual(3, 3.0)
isround(abs(3 - 3.0), 7) == 0
.How about replacing it with
pytest.approx(3) == 3.0
instead? [pytest docs]The text was updated successfully, but these errors were encountered: