Skip to content

Commit

Permalink
num_sec is passed as str in some cases. it was auto converted to int …
Browse files Browse the repository at this point in the history
…in py2 but it doesn't work in py3. let's add intentional float conversion
  • Loading branch information
izapolsk committed Jul 29, 2019
1 parent 2b84ae1 commit 0fc1c76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,11 @@ def test_nonnumeric_numsec_timedelta_via_string():
with pytest.raises(TimedOutError):
wait_for(func,
timeout="2s", delay=1)


def test_str_numsec():
incman = Incrementor()
func = partial(lambda: incman.i_sleep_a_lot() > 10)
for value in "2", "1.5":
with pytest.raises(TimedOutError):
wait_for(func, num_sec=value)
2 changes: 1 addition & 1 deletion wait_for/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _get_timeout_secs(kwargs):
else:
raise ValueError("Timeout got an unknown value {}".format(timeout))
else:
num_sec = kwargs.get('num_sec', 120)
num_sec = float(kwargs.get('num_sec', 120))
return num_sec


Expand Down

0 comments on commit 0fc1c76

Please sign in to comment.