Use both old and new fixtures for test
This commit is contained in:
parent
fc110ea418
commit
6d7096dc66
@ -918,236 +918,237 @@ def test_start_test_pairlist(mocker, caplog, tickers, default_conf, capsys):
|
|||||||
captured.out)
|
captured.out)
|
||||||
|
|
||||||
|
|
||||||
def test_hyperopt_list(mocker, capsys, caplog, saved_hyperopt_results):
|
def test_hyperopt_list(mocker, capsys, caplog, saved_hyperopt_results, saved_hyperopt_results_legacy):
|
||||||
mocker.patch(
|
for _ in (saved_hyperopt_results, saved_hyperopt_results_legacy):
|
||||||
'freqtrade.optimize.hyperopt_tools.HyperoptTools.load_previous_results',
|
mocker.patch(
|
||||||
MagicMock(return_value=saved_hyperopt_results)
|
'freqtrade.optimize.hyperopt_tools.HyperoptTools.load_previous_results',
|
||||||
)
|
MagicMock(return_value=saved_hyperopt_results_legacy)
|
||||||
|
)
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12",
|
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12",
|
||||||
" 6/12", " 7/12", " 8/12", " 9/12", " 10/12",
|
" 6/12", " 7/12", " 8/12", " 9/12", " 10/12",
|
||||||
" 11/12", " 12/12"])
|
" 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--best",
|
"--best",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 1/12", " 5/12", " 10/12"])
|
for x in [" 1/12", " 5/12", " 10/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 2/12", " 3/12", " 4/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
for x in [" 2/12", " 3/12", " 4/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
||||||
" 11/12", " 12/12"])
|
" 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--profitable",
|
"--profitable",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 2/12", " 10/12"])
|
for x in [" 2/12", " 10/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
||||||
" 11/12", " 12/12"])
|
" 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--profitable",
|
"--profitable",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 2/12", " 10/12", "Best result:", "Buy hyperspace params",
|
for x in [" 2/12", " 10/12", "Best result:", "Buy hyperspace params",
|
||||||
"Sell hyperspace params", "ROI table", "Stoploss"])
|
"Sell hyperspace params", "ROI table", "Stoploss"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
||||||
" 11/12", " 12/12"])
|
" 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--min-trades", "20",
|
"--min-trades", "20",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 3/12", " 6/12", " 7/12", " 9/12", " 11/12"])
|
for x in [" 3/12", " 6/12", " 7/12", " 9/12", " 11/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 2/12", " 4/12", " 5/12", " 8/12", " 10/12", " 12/12"])
|
for x in [" 1/12", " 2/12", " 4/12", " 5/12", " 8/12", " 10/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--profitable",
|
"--profitable",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--max-trades", "20",
|
"--max-trades", "20",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 2/12", " 10/12"])
|
for x in [" 2/12", " 10/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
||||||
" 11/12", " 12/12"])
|
" 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--profitable",
|
"--profitable",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--min-avg-profit", "0.11",
|
"--min-avg-profit", "0.11",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 2/12"])
|
for x in [" 2/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
||||||
" 10/12", " 11/12", " 12/12"])
|
" 10/12", " 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--max-avg-profit", "0.10",
|
"--max-avg-profit", "0.10",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 1/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
for x in [" 1/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12",
|
||||||
" 11/12"])
|
" 11/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 2/12", " 4/12", " 10/12", " 12/12"])
|
for x in [" 2/12", " 4/12", " 10/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--min-total-profit", "0.4",
|
"--min-total-profit", "0.4",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 10/12"])
|
for x in [" 10/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
||||||
" 9/12", " 11/12", " 12/12"])
|
" 9/12", " 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--max-total-profit", "0.4",
|
"--max-total-profit", "0.4",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
||||||
" 9/12", " 11/12"])
|
" 9/12", " 11/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 4/12", " 10/12", " 12/12"])
|
for x in [" 4/12", " 10/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--min-objective", "0.1",
|
"--min-objective", "0.1",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 10/12"])
|
for x in [" 10/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
||||||
" 9/12", " 11/12", " 12/12"])
|
" 9/12", " 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--max-objective", "0.1",
|
"--max-objective", "0.1",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
||||||
" 9/12", " 11/12"])
|
" 9/12", " 11/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 4/12", " 10/12", " 12/12"])
|
for x in [" 4/12", " 10/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--profitable",
|
"--profitable",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--min-avg-time", "2000",
|
"--min-avg-time", "2000",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 10/12"])
|
for x in [" 10/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12",
|
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12",
|
||||||
" 8/12", " 9/12", " 11/12", " 12/12"])
|
" 8/12", " 9/12", " 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--max-avg-time", "1500",
|
"--max-avg-time", "1500",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert all(x in captured.out
|
assert all(x in captured.out
|
||||||
for x in [" 2/12", " 6/12"])
|
for x in [" 2/12", " 6/12"])
|
||||||
assert all(x not in captured.out
|
assert all(x not in captured.out
|
||||||
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 7/12", " 8/12"
|
for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 7/12", " 8/12"
|
||||||
" 9/12", " 10/12", " 11/12", " 12/12"])
|
" 9/12", " 10/12", " 11/12", " 12/12"])
|
||||||
args = [
|
args = [
|
||||||
"hyperopt-list",
|
"hyperopt-list",
|
||||||
"--no-details",
|
"--no-details",
|
||||||
"--no-color",
|
"--no-color",
|
||||||
"--export-csv", "test_file.csv",
|
"--export-csv", "test_file.csv",
|
||||||
]
|
]
|
||||||
pargs = get_args(args)
|
pargs = get_args(args)
|
||||||
pargs['config'] = None
|
pargs['config'] = None
|
||||||
start_hyperopt_list(pargs)
|
start_hyperopt_list(pargs)
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
log_has("CSV file created: test_file.csv", caplog)
|
log_has("CSV file created: test_file.csv", caplog)
|
||||||
f = Path("test_file.csv")
|
f = Path("test_file.csv")
|
||||||
assert 'Best,1,2,-1.25%,-1.2222,-0.00125625,,-2.51,"3,930.0 m",0.43662' in f.read_text()
|
assert 'Best,1,2,-1.25%,-1.2222,-0.00125625,,-2.51,"3,930.0 m",0.43662' in f.read_text()
|
||||||
assert f.is_file()
|
assert f.is_file()
|
||||||
f.unlink()
|
f.unlink()
|
||||||
|
|
||||||
|
|
||||||
def test_hyperopt_show(mocker, capsys, saved_hyperopt_results):
|
def test_hyperopt_show(mocker, capsys, saved_hyperopt_results):
|
||||||
|
Loading…
Reference in New Issue
Block a user