Skip to content

Commit

Permalink
Fix timing assertion issue in test for pydash.delay where it could fa…
Browse files Browse the repository at this point in the history
…il on certain environments.

Fixes #175
  • Loading branch information
dgilland committed Sep 23, 2022
1 parent 56939f1 commit 5e11280
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,10 @@ def func():
"func,wait,args,kwargs,expected",
[(lambda a, b, c: (a, b, c), 250, (1, 2), {"c": 3}, (1, 2, 3))],
)
def test_delay(func, wait, args, kwargs, expected):
start = time.time() * 1000
def test_delay(mock_sleep, func, wait, args, kwargs, expected):
result = _.delay(func, wait, *args, **kwargs)
stop = time.time() * 1000

assert (wait - 10) <= (stop - start) <= (wait + 10)
assert result == expected
assert mock_sleep.call_args_list == [mock.call(pytest.approx(wait / 1000.0))]


@parametrize(
Expand Down

0 comments on commit 5e11280

Please sign in to comment.