Merge pull request #6112 from xataxxx/develop

Fix test not running when user_data contains historical data.
This commit is contained in:
Matthias 2021-12-25 10:11:15 +01:00 committed by GitHub
commit 49aa34c6f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
# pragma pylint: disable=missing-docstring,W0212,C0103 # pragma pylint: disable=missing-docstring,W0212,C0103
import os
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
from unittest.mock import ANY, MagicMock from unittest.mock import ANY, MagicMock
@ -169,6 +170,7 @@ def test_start_no_hyperopt_allowed(mocker, hyperopt_conf, caplog) -> None:
def test_start_no_data(mocker, hyperopt_conf) -> None: def test_start_no_data(mocker, hyperopt_conf) -> None:
hyperopt_conf['user_data_dir'] = Path("tests")
patched_configuration_load_config_file(mocker, hyperopt_conf) patched_configuration_load_config_file(mocker, hyperopt_conf)
mocker.patch('freqtrade.data.history.load_pair_history', MagicMock(return_value=pd.DataFrame)) mocker.patch('freqtrade.data.history.load_pair_history', MagicMock(return_value=pd.DataFrame))
mocker.patch( mocker.patch(
@ -189,6 +191,12 @@ def test_start_no_data(mocker, hyperopt_conf) -> None:
with pytest.raises(OperationalException, match='No data found. Terminating.'): with pytest.raises(OperationalException, match='No data found. Terminating.'):
start_hyperopt(pargs) start_hyperopt(pargs)
# Cleanup since that failed hyperopt start leaves a lockfile.
try:
os.unlink(Hyperopt.get_lock_filename(hyperopt_conf))
except Exception:
pass
def test_start_filelock(mocker, hyperopt_conf, caplog) -> None: def test_start_filelock(mocker, hyperopt_conf, caplog) -> None:
hyperopt_mock = MagicMock(side_effect=Timeout(Hyperopt.get_lock_filename(hyperopt_conf))) hyperopt_mock = MagicMock(side_effect=Timeout(Hyperopt.get_lock_filename(hyperopt_conf)))