tests: fix

This commit is contained in:
Meng Xiangzhuo
2024-10-30 22:11:37 +08:00
parent a417698fcd
commit 1aa863a92f
2 changed files with 5 additions and 5 deletions

View File

@@ -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):

View File

@@ -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,