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

Avoid checking floating point values for equality #32

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

NamelessOne91
Copy link
Contributor

Avoid a floating point values equality check in TestJunit::test_get_totals.

We have noticed the following failing test in #30

FAILED test/test_junit.py::TestJunit::test_get_totals - AssertionError: {'fai[29 chars]ped': 0, 'passed': 63, 'tests': 66, 'time': 1334.5865919999999} != {'fai[29 chars]ped': 0, 'passed': 63, 'tests': 66, 'time': 1334.586592}
  {'errors': 0,
   'failures': 3,
   'passed': 63,
   'skipped': 0,
   'tests': 66,
-  'time': 1334.5865919999999}
?                    ^^^^^^^^

+  'time': 1334.586592}

Looks like to be just a rounding difference due to floating point precision.
As that is often time dependent on architectures, programming languages etc it might be better to remove the equality check altogether and just check that the 2 values are really close

@nodeg
Copy link
Member

nodeg commented Feb 3, 2024

Thank you very much, Paolo, for taking a look so quickly and providing a fix.

@nodeg nodeg merged commit f475604 into uyuni-project:master Feb 7, 2024
1 check passed
@juliogonzalez
Copy link
Member

TIL about isclose. Nice fix!

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.

4 participants