Improve tests for newly added methods
This commit is contained in:
parent
b25ad68c44
commit
3503fdb4ec
@ -307,6 +307,18 @@ def test_roi_table_generation(hyperopt) -> None:
|
||||
assert hyperopt.custom_hyperopt.generate_roi_table(params) == {0: 6, 15: 3, 25: 1, 30: 0}
|
||||
|
||||
|
||||
def test_params_no_optimize_details(hyperopt) -> None:
|
||||
hyperopt.config['spaces'] = ['buy']
|
||||
res = hyperopt._get_no_optimize_details()
|
||||
assert isinstance(res, dict)
|
||||
assert "trailing" in res
|
||||
assert res["trailing"]['trailing_stop'] is False
|
||||
assert "roi" in res
|
||||
assert res['roi']['0'] == 0.04
|
||||
assert "stoploss" in res
|
||||
assert res['stoploss']['stoploss'] == -0.1
|
||||
|
||||
|
||||
def test_start_calls_optimizer(mocker, hyperopt_conf, capsys) -> None:
|
||||
dumper = mocker.patch('freqtrade.optimize.hyperopt.dump')
|
||||
dumper2 = mocker.patch('freqtrade.optimize.hyperopt.Hyperopt._save_result')
|
||||
|
@ -2,13 +2,14 @@ import logging
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Dict, List
|
||||
import numpy as np
|
||||
|
||||
import pytest
|
||||
import rapidjson
|
||||
|
||||
from freqtrade.constants import FTHYPT_FILEVERSION
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.optimize.hyperopt_tools import HyperoptTools
|
||||
from freqtrade.optimize.hyperopt_tools import HyperoptTools, hyperopt_serializer
|
||||
from tests.conftest import log_has, log_has_re
|
||||
|
||||
|
||||
@ -307,3 +308,10 @@ def test_params_print(capsys):
|
||||
assert re.search('trailing_stop_positive = 0.05 # value loaded.*\n', captured.out)
|
||||
assert re.search('trailing_stop_positive_offset = 0.1 # value loaded.*\n', captured.out)
|
||||
assert re.search('trailing_only_offset_is_reached = True # value loaded.*\n', captured.out)
|
||||
|
||||
|
||||
def test_hyperopt_serializer():
|
||||
|
||||
assert isinstance(hyperopt_serializer(np.int_(5)), int)
|
||||
assert isinstance(hyperopt_serializer(np.bool_(True)), bool)
|
||||
assert isinstance(hyperopt_serializer(np.bool_(False)), bool)
|
Loading…
Reference in New Issue
Block a user