projects
/
swc-testing-nose.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c716d9b
)
Add example floating point testing to cheat sheet.
author
Ben Waugh
<b.waugh@ucl.ac.uk>
Wed, 10 Apr 2013 21:19:42 +0000
(22:19 +0100)
committer
W. Trevor King
<wking@tremily.us>
Fri, 1 Nov 2013 20:42:44 +0000
(13:42 -0700)
testing/cheat-sheet.md
patch
|
blob
|
history
diff --git
a/testing/cheat-sheet.md
b/testing/cheat-sheet.md
index 3047fca887783b102f13e12e622288cb53e55037..f79244720b59b78c5b807b16825be0d2b9f0db6b 100644
(file)
--- a/
testing/cheat-sheet.md
+++ b/
testing/cheat-sheet.md
@@
-72,7
+72,17
@@
Nose provides a range of assertions that can be used when a test is not just che
### Floating point tests
-* assert_almost_equal...
+When comparing floating-point numbers for equality, allow some tolerance for small differences due to
+the way values are represented and rounded.
+
+ from nose.tools import assert_almost_equal
+
+ from mycode import hypotenuse
+
+ def test_hypotenuse_345():
+ observed = hypotenuse(3.0, 4.0)
+ expected = 5.0
+ assert_almost_equal(observed, expected)
### Fixtures