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

Use pytest.approx in fixes.AlmostOp #66

Closed
wants to merge 1 commit into from

Conversation

janosh
Copy link
Contributor

@janosh janosh commented Jan 20, 2023

Closes #63.

Change AlmostOp() to rewrite self.assertAlmostEqual(3, 3.0) to 3 == approx(3.0) instead of round(abs(3 - 3.0), 7) == 0.

Still needs tests. Also currently requires adding from pytest import approx though that can be done with something like isort --add-import 'from pytest import approx' $(git status -s | cut -c4-).

Here's an example diff generated by the new AlmostOp():

Screenshot 2023-01-19 at 21 09 25

…pprox(3.0) instead of round(abs(3 - 3.0), 7) == 0
@janosh janosh changed the title approx-in-almost-op Use pytest.approx in fixes.AlmostOp Jan 20, 2023
@janosh janosh closed this by deleting the head repository Oct 10, 2024
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.

pytest.approx for self.assertAlmostEqual
1 participant