tests didn't pass fxrange

This commit is contained in:
Ask Solem 2011-01-07 11:22:05 +01:00
parent 387e979840
commit eed34140ae
2 changed files with 12 additions and 11 deletions

View File

@ -182,7 +182,7 @@ def insomnia(fun):
return _inner return _inner
class test_retry_over_Time(unittest.TestCase): class test_retry_over_time(unittest.TestCase):
@insomnia @insomnia
def test_simple(self): def test_simple(self):
@ -193,15 +193,15 @@ class test_retry_over_Time(unittest.TestCase):
def myfun(): def myfun():
sleepvals = {0: None, sleepvals = {0: None,
1: 2, 1: 2.0,
2: 4, 2: 4.0,
3: 6, 3: 6.0,
4: 8, 4: 8.0,
5: 10, 5: 10.0,
6: 12, 6: 12.0,
7: 14, 7: 14.0,
8: 14, 8: 16.0,
9: 14} 9: 16.0}
self.assertEqual(_tried_to_sleep[0], sleepvals[index[0]]) self.assertEqual(_tried_to_sleep[0], sleepvals[index[0]])
if index[0] < 9: if index[0] < 9:
raise Predicate() raise Predicate()

View File

@ -62,7 +62,8 @@ def fxrange(start=1.0, stop=None, step=1.0, repeatlast=False):
while 1: while 1:
if cur <= stop: if cur <= stop:
yield cur yield cur
cur += step if cur + step <= stop:
cur += step
else: else:
if not repeatlast: if not repeatlast:
break break