def test_delay(func, wait, args, kargs, expected): start = time.time() * 1000 result = _.delay(func, wait, *args, **kargs) stop = time.time() * 1000 assert (wait - 5) <= (stop - start) <= (wait + 5) assert result == expected