Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
S slapos.core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 26
    • Merge requests 26
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • slapos.core
  • Merge requests
  • !719

You need to sign in or sign up before continuing.
Merged
Created Nov 28, 2024 by Titouan Soulard@tsoulardDeveloper

tests: use `assertAlmostEqual` for float comparison

  • Overview 3
  • Commits 1
  • Pipelines 2
  • Changes 1

Floating point arithmetics often lead to unsignificant differences between expected and computed values (this is the typical example of 0.1 + 0.2 != 0.3). Because of this, some tests using assertEqual to compare two floats were failing. The Python method [assertAlmostEqual](https://docs.python.org/2.7/library/unittest.html#unittest .TestCase.assertAlmostEqual) can prevent these issues by comparing values up to the seventh decimal place. To find all occurences, two RegExp were ran on all files of the tests/ folder: assertEquals?(\\(.+, [0-9]+\\.[0-9]+\\)) and assertEquals?(\\([0-9]+\\.[0-9]+).

Goes in part with similar MR in slapos.toolbox.

/cc @jerome @xavier_thompson

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: for-mr-duck
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7