diff --git a/tests/test_simple.py b/tests/test_simple.py index 7d165ba..24d4ebe 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -114,3 +114,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) diff --git a/wait_for/__init__.py b/wait_for/__init__.py index 1a0a276..e39f4cc 100644 --- a/wait_for/__init__.py +++ b/wait_for/__init__.py @@ -44,7 +44,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