From 1aa863a92f683eca0ef351b73178907e73aec726 Mon Sep 17 00:00:00 2001 From: Meng Xiangzhuo Date: Wed, 30 Oct 2024 22:11:37 +0800 Subject: [PATCH] tests: fix --- freqtrade/exchange/binance_public_data.py | 4 ++-- tests/data/test_history.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/freqtrade/exchange/binance_public_data.py b/freqtrade/exchange/binance_public_data.py index 007886606..ea4f4bc58 100644 --- a/freqtrade/exchange/binance_public_data.py +++ b/freqtrade/exchange/binance_public_data.py @@ -5,7 +5,6 @@ Fetch daily-archived OHLCV data from https://data.binance.vision/ import asyncio import datetime import io -import itertools import logging import zipfile @@ -14,6 +13,7 @@ import pandas as pd from pandas import DataFrame from freqtrade.enums import CandleType +from freqtrade.misc import chunks from freqtrade.util.datetime_helpers import dt_from_ts, dt_now @@ -106,7 +106,7 @@ async def _fetch_ohlcv( for date in date_range(start, end) ] # the HTTP connections has been throttled by TCPConnector - for batch in itertools.batched(coroutines, 1000): + for batch in chunks(coroutines, 1000): results = await asyncio.gather(*batch) for result in results: if isinstance(result, BaseException): diff --git a/tests/data/test_history.py b/tests/data/test_history.py index b505c4fe3..465a0ee1a 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -128,8 +128,8 @@ def test_load_data_with_new_pair_1min( """ Test load_pair_history() with 1 min timeframe """ - mocker.patch(f"{EXMS}.get_historic_ohlcv", return_value=ohlcv_history) exchange = get_patched_exchange(mocker, default_conf) + mocker.patch.object(exchange, "get_historic_ohlcv", return_value=ohlcv_history) file = tmp_path / "MEME_BTC-1m.feather" # do not download a new pair if refresh_pairs isn't set @@ -305,8 +305,8 @@ def test_load_cached_data_for_updating(mocker, testdatadir) -> None: def test_download_pair_history( ohlcv_history, mocker, default_conf, tmp_path, candle_type, subdir, file_tail ) -> None: - mocker.patch(f"{EXMS}.get_historic_ohlcv", return_value=ohlcv_history) exchange = get_patched_exchange(mocker, default_conf) + mocker.patch.object(exchange, "get_historic_ohlcv", return_value=ohlcv_history) file1_1 = tmp_path / f"{subdir}MEME_BTC-1m{file_tail}.feather" file1_5 = tmp_path / f"{subdir}MEME_BTC-5m{file_tail}.feather" file2_1 = tmp_path / f"{subdir}CFI_BTC-1m{file_tail}.feather" @@ -356,8 +356,8 @@ def test_download_pair_history2(mocker, default_conf, testdatadir, ohlcv_history "freqtrade.data.history.datahandlers.featherdatahandler.FeatherDataHandler.ohlcv_store", return_value=None, ) - mocker.patch(f"{EXMS}.get_historic_ohlcv", return_value=ohlcv_history) exchange = get_patched_exchange(mocker, default_conf) + mocker.patch.object(exchange, "get_historic_ohlcv", return_value=ohlcv_history) _download_pair_history( datadir=testdatadir, exchange=exchange,