Skip to content

A flake8 plugin to check for the use of round() in assertEqual and assertAlmostEqual

License

Notifications You must be signed in to change notification settings

MarkusPiotrowski/flake8-assertAlmostEqual

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flake8-assertAlmostEqual

A Flake8 plugin to check for the use of round() in assertEqual and assertAlmostEqual.

It detects and flags two issues:

  • AAE100 Don't use 'assertAlmostEqual' with 'round'. Use it's implemented rounding.
  • AAE110 Don't use 'assertEqual' with 'round'. Use 'assertAlmostEqual' instead.

Don't use assertAlmostEqual with round... (AAE100)

assertAlmostEqual has built in rounding. Thus round() is not required.

Anti-pattern

assertAlmostEqual(round(my_result, 2), 1.52)

Best practice

assertAlmostEqual(my_result, 1.52, 2)

Don't use assertEqual with round... (AAE110)

If you need rounding, don't use assertEqual. Use assertAlmostEqual instead.

Anti-pattern

assertEqual(round(my_result, 2), 1.52)

Best practice

assertAlmostEqual(my_result, 1.52, 2)

About

A flake8 plugin to check for the use of round() in assertEqual and assertAlmostEqual

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages