()
| 15 | import ccxt.async_support as ccxt # noqa: F402 |
| 16 | |
| 17 | async 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 |
no test coverage detected
searching dependent graphs…