Skip to content

Commit 44ec500

Browse files
committed
test: add Test-case to ensure hyperopt logging
1 parent 8526733 commit 44ec500

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tests/optimize/test_hyperopt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,9 @@ def test_in_strategy_auto_hyperopt(mocker, hyperopt_conf, tmp_path, fee) -> None
11321132

11331133

11341134
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
1135-
def test_in_strategy_auto_hyperopt_with_parallel(mocker, hyperopt_conf, tmp_path, fee) -> None:
1135+
def test_in_strategy_auto_hyperopt_with_parallel(
1136+
mocker, hyperopt_conf, tmp_path, fee, caplog
1137+
) -> None:
11361138
mocker.patch(f"{EXMS}.validate_config", MagicMock())
11371139
mocker.patch(f"{EXMS}.get_fee", fee)
11381140
mocker.patch(f"{EXMS}.reload_markets")
@@ -1175,6 +1177,8 @@ def test_in_strategy_auto_hyperopt_with_parallel(mocker, hyperopt_conf, tmp_path
11751177
assert len(list(buy_rsi_range)) == 51
11761178

11771179
hyperopt.start()
1180+
# Test logs from parallel workers are shown.
1181+
assert log_has("Test: Bot loop started", caplog)
11781182

11791183

11801184
def test_in_strategy_auto_hyperopt_per_epoch(mocker, hyperopt_conf, tmp_path, fee) -> None:

tests/strategy/strats/hyperoptable_strategy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
22

3+
import logging
4+
35
from pandas import DataFrame
46
from strategy_test_v3 import StrategyTestV3
57

68
import freqtrade.vendor.qtpylib.indicators as qtpylib
79
from freqtrade.strategy import BooleanParameter, DecimalParameter, IntParameter, RealParameter
810

911

12+
logger = logging.getLogger(__name__)
13+
14+
1015
class HyperoptableStrategy(StrategyTestV3):
1116
"""
1217
Default Strategy provided by freqtrade bot.
@@ -55,6 +60,7 @@ def protections(self):
5560

5661
def bot_loop_start(self, **kwargs):
5762
self.bot_loop_started = True
63+
logger.info("Test: Bot loop started")
5864

5965
def bot_start(self, **kwargs) -> None:
6066
self.bot_started = True

0 commit comments

Comments
 (0)