[TIP] newb - nose and floating point values
Carl Trachte
ctrachte at gmail.com
Sun Feb 24 16:11:16 PST 2008
Sorry if this is an FAQ; I googled and came up empty:
Is this the appropriate way to test for floating point return values from a
function (with nose)?
# begin code
FLTTOL = 0.00001
def addtwonumbers(num1, num2):
return num1 + num2
def test_addtwonumbers():
assert addtwonumbers(4, 6) == 10
assert addtwonumbers(8, 32) == 40
assert abs(addtwonumbers(4.3, -2.1) - 2.2) < FLTTOL
# end code
Thanks a ton.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/testing-in-python/attachments/20080224/2b2199e7/attachment.htm
More information about the testing-in-python
mailing list