Testcase added

This commit is contained in:
hroff-1902 2019-11-23 12:30:49 +03:00
parent 067267f4cf
commit 6cb4830534

View File

@ -383,14 +383,19 @@ def test_no_log_if_loss_does_not_improve(hyperopt, caplog) -> None:
def test_save_trials_saves_trials(mocker, hyperopt, testdatadir, caplog) -> None: def test_save_trials_saves_trials(mocker, hyperopt, testdatadir, caplog) -> None:
trials = create_trials(mocker, hyperopt, testdatadir) trials = create_trials(mocker, hyperopt, testdatadir)
mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None) mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None)
trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
hyperopt.trials = trials hyperopt.trials = trials
hyperopt.save_trials(final=True) hyperopt.save_trials(final=True)
trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
assert log_has("Saving 1 epoch.", caplog) assert log_has("Saving 1 epoch.", caplog)
assert log_has(f"1 epoch saved to '{trials_file}'.", caplog) assert log_has(f"1 epoch saved to '{trials_file}'.", caplog)
mock_dump.assert_called_once() mock_dump.assert_called_once()
hyperopt.trials = trials + trials
hyperopt.save_trials(final=True)
assert log_has("Saving 2 epochs.", caplog)
assert log_has(f"2 epochs saved to '{trials_file}'.", caplog)
def test_read_trials_returns_trials_file(mocker, hyperopt, testdatadir, caplog) -> None: def test_read_trials_returns_trials_file(mocker, hyperopt, testdatadir, caplog) -> None:
trials = create_trials(mocker, hyperopt, testdatadir) trials = create_trials(mocker, hyperopt, testdatadir)