test: add Test-case to ensure hyperopt logging

This commit is contained in:
Matthias
2025-10-19 12:59:08 +02:00
parent 8526733b36
commit 44ec500744
2 changed files with 11 additions and 1 deletions

View File

@@ -1132,7 +1132,9 @@ def test_in_strategy_auto_hyperopt(mocker, hyperopt_conf, tmp_path, fee) -> None
@pytest.mark.filterwarnings("ignore::DeprecationWarning") @pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_in_strategy_auto_hyperopt_with_parallel(mocker, hyperopt_conf, tmp_path, fee) -> None: def test_in_strategy_auto_hyperopt_with_parallel(
mocker, hyperopt_conf, tmp_path, fee, caplog
) -> None:
mocker.patch(f"{EXMS}.validate_config", MagicMock()) mocker.patch(f"{EXMS}.validate_config", MagicMock())
mocker.patch(f"{EXMS}.get_fee", fee) mocker.patch(f"{EXMS}.get_fee", fee)
mocker.patch(f"{EXMS}.reload_markets") mocker.patch(f"{EXMS}.reload_markets")
@@ -1175,6 +1177,8 @@ def test_in_strategy_auto_hyperopt_with_parallel(mocker, hyperopt_conf, tmp_path
assert len(list(buy_rsi_range)) == 51 assert len(list(buy_rsi_range)) == 51
hyperopt.start() hyperopt.start()
# Test logs from parallel workers are shown.
assert log_has("Test: Bot loop started", caplog)
def test_in_strategy_auto_hyperopt_per_epoch(mocker, hyperopt_conf, tmp_path, fee) -> None: def test_in_strategy_auto_hyperopt_per_epoch(mocker, hyperopt_conf, tmp_path, fee) -> None:

View File

@@ -1,5 +1,7 @@
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
import logging
from pandas import DataFrame from pandas import DataFrame
from strategy_test_v3 import StrategyTestV3 from strategy_test_v3 import StrategyTestV3
@@ -7,6 +9,9 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib
from freqtrade.strategy import BooleanParameter, DecimalParameter, IntParameter, RealParameter from freqtrade.strategy import BooleanParameter, DecimalParameter, IntParameter, RealParameter
logger = logging.getLogger(__name__)
class HyperoptableStrategy(StrategyTestV3): class HyperoptableStrategy(StrategyTestV3):
""" """
Default Strategy provided by freqtrade bot. Default Strategy provided by freqtrade bot.
@@ -55,6 +60,7 @@ class HyperoptableStrategy(StrategyTestV3):
def bot_loop_start(self, **kwargs): def bot_loop_start(self, **kwargs):
self.bot_loop_started = True self.bot_loop_started = True
logger.info("Test: Bot loop started")
def bot_start(self, **kwargs) -> None: def bot_start(self, **kwargs) -> None:
self.bot_started = True self.bot_started = True