def test_hyperopt_show(mocker, capsys, saved_hyperopt_results): mocker.patch( 'freqtrade.optimize.hyperopt_tools.HyperoptTools.load_previous_results', MagicMock(return_value=saved_hyperopt_results) ) mocker.patch('freqtrade.commands.hyperopt_commands.show_backtest_result') args = [ "hyperopt-show", ] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 12/12" in captured.out args = [ "hyperopt-show", "--best" ] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 10/12" in captured.out args = [ "hyperopt-show", "-n", "1" ] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 1/12" in captured.out args = [ "hyperopt-show", "--best", "-n", "2" ] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 5/12" in captured.out args = [ "hyperopt-show", "--best", "-n", "-1" ] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 10/12" in captured.out args = [ "hyperopt-show", "--best", "-n", "-4" ] pargs = get_args(args) pargs['config'] = None with pytest.raises(OperationalException, match="The index of the epoch to show should be greater than -4."): start_hyperopt_show(pargs) args = [ "hyperopt-show", "--best", "-n", "4" ] pargs = get_args(args) pargs['config'] = None with pytest.raises(OperationalException, match="The index of the epoch to show should be less than 4."): start_hyperopt_show(pargs)
def test_hyperopt_show(mocker, capsys, saved_hyperopt_results): mocker.patch( 'freqtrade.optimize.hyperopt_tools.HyperoptTools._test_hyperopt_results_exist', return_value=True) def fake_iterator(*args, **kwargs): yield from [saved_hyperopt_results] mocker.patch( 'freqtrade.optimize.hyperopt_tools.HyperoptTools._read_results', side_effect=fake_iterator) mocker.patch('freqtrade.commands.hyperopt_commands.show_backtest_result') args = [ "hyperopt-show", ] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 12/12" in captured.out args = ["hyperopt-show", "--best"] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 10/12" in captured.out args = ["hyperopt-show", "-n", "1"] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 1/12" in captured.out args = ["hyperopt-show", "--best", "-n", "2"] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 5/12" in captured.out args = ["hyperopt-show", "--best", "-n", "-1"] pargs = get_args(args) pargs['config'] = None start_hyperopt_show(pargs) captured = capsys.readouterr() assert " 10/12" in captured.out args = ["hyperopt-show", "--best", "-n", "-4"] pargs = get_args(args) pargs['config'] = None with pytest.raises( OperationalException, match="The index of the epoch to show should be greater than -4."): start_hyperopt_show(pargs) args = ["hyperopt-show", "--best", "-n", "4"] pargs = get_args(args) pargs['config'] = None with pytest.raises( OperationalException, match="The index of the epoch to show should be less than 4."): start_hyperopt_show(pargs)