|
1 | 1 | import pytest |
| 2 | +import pytest_asyncio |
2 | 3 | from binance.client import Client |
3 | 4 | from binance.async_client import AsyncClient |
4 | 5 | import os |
@@ -61,21 +62,27 @@ def futuresClient(): |
61 | 62 | ) |
62 | 63 |
|
63 | 64 |
|
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() |
67 | 70 |
|
68 | 71 |
|
69 | | -@pytest.fixture(scope="function") |
70 | | -def futuresClientAsync(): |
71 | | - return AsyncClient( |
| 72 | +@pytest_asyncio.fixture(scope="function") |
| 73 | +async def futuresClientAsync(): |
| 74 | + client = AsyncClient( |
72 | 75 | futures_api_key, futures_api_secret, https_proxy=proxy, testnet=testnet |
73 | 76 | ) |
| 77 | + yield client |
| 78 | + await client.close_connection() |
74 | 79 |
|
75 | 80 |
|
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() |
79 | 86 |
|
80 | 87 | @pytest.fixture(scope="function") |
81 | 88 | def manager(): |
|
0 commit comments