Skip to content

Commit ea89084

Browse files
committed
cleanup client
1 parent 323c753 commit ea89084

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

tests/conftest.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import pytest_asyncio
23
from binance.client import Client
34
from binance.async_client import AsyncClient
45
import os
@@ -61,21 +62,27 @@ def futuresClient():
6162
)
6263

6364

64-
@pytest.fixture(scope="function")
65-
def clientAsync():
66-
return AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=testnet)
65+
@pytest_asyncio.fixture(scope="function")
66+
async def clientAsync():
67+
client = AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=testnet)
68+
yield client
69+
await client.close_connection()
6770

6871

69-
@pytest.fixture(scope="function")
70-
def futuresClientAsync():
71-
return AsyncClient(
72+
@pytest_asyncio.fixture(scope="function")
73+
async def futuresClientAsync():
74+
client = AsyncClient(
7275
futures_api_key, futures_api_secret, https_proxy=proxy, testnet=testnet
7376
)
77+
yield client
78+
await client.close_connection()
7479

7580

76-
@pytest.fixture(scope="function")
77-
def liveClientAsync():
78-
return AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=False)
81+
@pytest_asyncio.fixture(scope="function")
82+
async def liveClientAsync():
83+
client = AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=False)
84+
yield client
85+
await client.close_connection()
7986

8087
@pytest.fixture(scope="function")
8188
def manager():

0 commit comments

Comments
 (0)