test: added retries for trade tests

api-breakage
Morty Space 4 years ago
parent e6a5550841
commit 9f369ec1a7
  1. 24
      tests/test_private.py

@ -1,4 +1,5 @@
import asyncio
import functools
import time
import async_timeout
@ -12,6 +13,26 @@ from cryptocom.exchange.structs import (
)
def retry(times: int):
"""Retry function for unstable tests."""
def decorator(f):
@functools.wraps(f)
async def wrapper(*args, **kwargs):
nonlocal times
while True:
try:
return await f(*args, **kwargs)
except Exception as exc:
times -= 1
if not times:
raise exc
return wrapper
return decorator
@pytest.mark.asyncio
async def test_account_get_balance(account: cro.Account):
balances = await account.get_balance()
@ -63,6 +84,7 @@ async def test_deposit_withdrawal_history(
@pytest.mark.asyncio
@retry(5)
async def test_no_duplicate_mass_limit_orders(
exchange: cro.Exchange, account: cro.Account
):
@ -93,6 +115,7 @@ async def test_no_duplicate_mass_limit_orders(
@pytest.mark.asyncio
@retry(5)
async def test_account_limit_orders(
account: cro.Account, exchange: cro.Exchange
):
@ -156,6 +179,7 @@ async def listen_orders(account: cro.Account, orders):
@pytest.mark.asyncio
@retry(5)
async def test_account_market_orders(
account: cro.Account, exchange: cro.Exchange
):

Loading…
Cancel
Save