def test_window_decorator_timing():
from time import monotonic
limiter = FixedWindowRateLimiter(SECONDS, PERMITS)
@limiter.limit
def call():
return monotonic()
times = []
for _ in range(VALUE_COUNT):
times.append(call())
start_indexes = [i for i in range(VALUE_COUNT) if i % PERMITS == 0]
last = -SECONDS
for index in start_indexes:
assert times[index] - last >= SECONDS - EPSILON
last = times[index]
评论列表
文章目录