From 44ec500744c612c06d6014c17b31a637f492270e Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 19 Oct 2025 12:59:08 +0200 Subject: [PATCH] test: add Test-case to ensure hyperopt logging --- tests/optimize/test_hyperopt.py | 6 +++++- tests/strategy/strats/hyperoptable_strategy.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/optimize/test_hyperopt.py b/tests/optimize/test_hyperopt.py index 21f011a9b..f778f64af 100644 --- a/tests/optimize/test_hyperopt.py +++ b/tests/optimize/test_hyperopt.py @@ -1132,7 +1132,9 @@ def test_in_strategy_auto_hyperopt(mocker, hyperopt_conf, tmp_path, fee) -> None @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}.get_fee", fee) 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 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: diff --git a/tests/strategy/strats/hyperoptable_strategy.py b/tests/strategy/strats/hyperoptable_strategy.py index f22623f7c..c5b23a52a 100644 --- a/tests/strategy/strats/hyperoptable_strategy.py +++ b/tests/strategy/strats/hyperoptable_strategy.py @@ -1,5 +1,7 @@ # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement +import logging + from pandas import DataFrame 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 +logger = logging.getLogger(__name__) + + class HyperoptableStrategy(StrategyTestV3): """ Default Strategy provided by freqtrade bot. @@ -55,6 +60,7 @@ class HyperoptableStrategy(StrategyTestV3): def bot_loop_start(self, **kwargs): self.bot_loop_started = True + logger.info("Test: Bot loop started") def bot_start(self, **kwargs) -> None: self.bot_started = True