Skip to content

Commit

Permalink
Rename Hyperopt Test Class
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Aug 26, 2021
1 parent 0d8e105 commit df1c054
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tests/commands/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def test_start_list_hyperopts(mocker, caplog, capsys):
captured = capsys.readouterr()
assert "TestHyperoptLegacy" not in captured.out
assert "legacy_hyperopt.py" not in captured.out
assert "DefaultHyperOpt" in captured.out
assert "HyperoptTestSepFile" in captured.out
assert "test_hyperopt.py" not in captured.out

# Test regular output
Expand All @@ -854,7 +854,7 @@ def test_start_list_hyperopts(mocker, caplog, capsys):
captured = capsys.readouterr()
assert "TestHyperoptLegacy" not in captured.out
assert "legacy_hyperopt.py" not in captured.out
assert "DefaultHyperOpt" in captured.out
assert "HyperoptTestSepFile" in captured.out


def test_start_test_pairlist(mocker, caplog, tickers, default_conf, capsys):
Expand Down
2 changes: 1 addition & 1 deletion tests/optimize/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def hyperopt_conf(default_conf):
hyperconf.update({
'datadir': Path(default_conf['datadir']),
'runmode': RunMode.HYPEROPT,
'hyperopt': 'DefaultHyperOpt',
'hyperopt': 'HyperoptTestSepFile',
'hyperopt_loss': 'ShortTradeDurHyperOptLoss',
'hyperopt_path': str(Path(__file__).parent / 'hyperopts'),
'epochs': 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from freqtrade.optimize.hyperopt_interface import IHyperOpt


class DefaultHyperOpt(IHyperOpt):
class HyperoptTestSepFile(IHyperOpt):
"""
Default hyperopt provided by the Freqtrade bot.
You can override it with your own Hyperopt
Expand Down
20 changes: 10 additions & 10 deletions tests/optimize/test_hyperopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,
patched_configuration_load_config_file)

from .hyperopts.default_hyperopt import DefaultHyperOpt
from .hyperopts.hyperopt_test_sep_file import HyperoptTestSepFile


def test_setup_hyperopt_configuration_without_arguments(mocker, default_conf, caplog) -> None:
Expand All @@ -31,7 +31,7 @@ def test_setup_hyperopt_configuration_without_arguments(mocker, default_conf, ca
args = [
'hyperopt',
'--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt',
'--hyperopt', 'HyperoptTestSepFile',
]

config = setup_optimize_configuration(get_args(args), RunMode.HYPEROPT)
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_setup_hyperopt_configuration_with_arguments(mocker, default_conf, caplo
args = [
'hyperopt',
'--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt',
'--hyperopt', 'HyperoptTestSepFile',
'--datadir', '/foo/bar',
'--timeframe', '1m',
'--timerange', ':100',
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_setup_hyperopt_configuration_stake_amount(mocker, default_conf) -> None
args = [
'hyperopt',
'--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt',
'--hyperopt', 'HyperoptTestSepFile',
'--stake-amount', '1',
'--starting-balance', '2'
]
Expand All @@ -136,15 +136,15 @@ def test_setup_hyperopt_configuration_stake_amount(mocker, default_conf) -> None
def test_hyperoptresolver(mocker, default_conf, caplog) -> None:
patched_configuration_load_config_file(mocker, default_conf)

hyperopt = DefaultHyperOpt
hyperopt = HyperoptTestSepFile
delattr(hyperopt, 'populate_indicators')
delattr(hyperopt, 'populate_buy_trend')
delattr(hyperopt, 'populate_sell_trend')
mocker.patch(
'freqtrade.resolvers.hyperopt_resolver.HyperOptResolver.load_object',
MagicMock(return_value=hyperopt(default_conf))
)
default_conf.update({'hyperopt': 'DefaultHyperOpt'})
default_conf.update({'hyperopt': 'HyperoptTestSepFile'})
x = HyperOptResolver.load_hyperopt(default_conf)
assert not hasattr(x, 'populate_indicators')
assert not hasattr(x, 'populate_buy_trend')
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_start_not_installed(mocker, default_conf, import_fails) -> None:
args = [
'hyperopt',
'--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt',
'--hyperopt', 'HyperoptTestSepFile',
'--hyperopt-path',
str(Path(__file__).parent / "hyperopts"),
'--epochs', '5',
Expand All @@ -205,7 +205,7 @@ def test_start(mocker, hyperopt_conf, caplog) -> None:
args = [
'hyperopt',
'--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt',
'--hyperopt', 'HyperoptTestSepFile',
'--hyperopt-loss', 'SharpeHyperOptLossDaily',
'--epochs', '5'
]
Expand All @@ -229,7 +229,7 @@ def test_start_no_data(mocker, hyperopt_conf) -> None:
args = [
'hyperopt',
'--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt',
'--hyperopt', 'HyperoptTestSepFile',
'--hyperopt-loss', 'SharpeHyperOptLossDaily',
'--epochs', '5'
]
Expand All @@ -247,7 +247,7 @@ def test_start_filelock(mocker, hyperopt_conf, caplog) -> None:
args = [
'hyperopt',
'--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt',
'--hyperopt', 'HyperoptTestSepFile',
'--hyperopt-loss', 'SharpeHyperOptLossDaily',
'--epochs', '5'
]
Expand Down

0 comments on commit df1c054

Please sign in to comment.