MCPcopy Create free account
hub / github.com/ccxt/ccxt / test_sleep

Function test_sleep

python/ccxt/test/base/test_sleep.py:17–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15import ccxt.async_support as ccxt # noqa: F402
16
17async def test_sleep():
18 exchange = ccxt.Exchange({
19 'id': 'sampleexchange',
20 })
21 start = exchange.milliseconds()
22 sleep_amount = 100 # milliseconds
23 await exchange.sleep(sleep_amount)
24 end = exchange.milliseconds()
25 elapsed = end - start
26 # Allow a small margin of error due to execution time
27 margin_of_error = 20
28 max_elapsed = sleep_amount + margin_of_error
29 elapsed_bigger_than_sleep = elapsed >= sleep_amount
30 elapsed_less_than_max = elapsed <= max_elapsed
31 assert elapsed_bigger_than_sleep, 'Elapsed time ' + str(elapsed) + 'ms is less than sleep amount ' + str(sleep_amount) + 'ms'
32 assert elapsed_less_than_max, 'Elapsed time ' + str(elapsed) + 'ms exceeds sleep amount ' + str(max_elapsed) + 'ms'
33 return True

Callers 1

base_tests_initFunction · 0.90

Calls 3

millisecondsMethod · 0.95
sleepMethod · 0.95
ExchangeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…