Fix paths in tests

This commit is contained in:
Matthias 2019-09-08 10:07:09 +02:00
parent f2cbc5fb8f
commit 9513115ce0
4 changed files with 13 additions and 14 deletions

View File

@ -160,7 +160,7 @@ def test_load_data_live_noexchange(default_conf, mocker, caplog, testdatadir) ->
def test_testdata_path(testdatadir) -> None:
assert str(Path('freqtrade') / 'tests' / 'testdata') in str(testdatadir)
assert str(Path('tests') / 'testdata') in str(testdatadir)
def test_load_cached_data_for_updating(mocker) -> None:

View File

@ -1,5 +1,4 @@
# pragma pylint: disable=missing-docstring,W0212,C0103
import os
from datetime import datetime
from pathlib import Path
from unittest.mock import MagicMock, PropertyMock
@ -54,7 +53,7 @@ def create_trials(mocker, hyperopt, testdatadir) -> None:
- we might have a pickle'd file so make sure that we return
false when looking for it
"""
hyperopt.trials_file = testdatadir / '/optimize/ut_trials.pickle'
hyperopt.trials_file = testdatadir / 'optimize/ut_trials.pickle'
mocker.patch.object(Path, "is_file", MagicMock(return_value=False))
stat_mock = MagicMock()
@ -356,23 +355,23 @@ def test_no_log_if_loss_does_not_improve(hyperopt, caplog) -> None:
assert caplog.record_tuples == []
def test_save_trials_saves_trials(mocker, hyperopt, caplog) -> None:
trials = create_trials(mocker, hyperopt)
def test_save_trials_saves_trials(mocker, hyperopt, testdatadir, caplog) -> None:
trials = create_trials(mocker, hyperopt, testdatadir)
mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None)
hyperopt.trials = trials
hyperopt.save_trials()
trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle')
assert log_has("Saving 1 evaluations to '{}'".format(trials_file), caplog)
trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
assert log_has(f"Saving 1 evaluations to '{trials_file}'", caplog)
mock_dump.assert_called_once()
def test_read_trials_returns_trials_file(mocker, hyperopt, caplog) -> None:
trials = create_trials(mocker, hyperopt)
def test_read_trials_returns_trials_file(mocker, hyperopt, testdatadir, caplog) -> None:
trials = create_trials(mocker, hyperopt, testdatadir)
mock_load = mocker.patch('freqtrade.optimize.hyperopt.load', return_value=trials)
hyperopt_trial = hyperopt.read_trials()
trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle')
assert log_has("Reading Trials from '{}'".format(trials_file), caplog)
trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
assert log_has(f"Reading Trials from '{trials_file}'", caplog)
assert hyperopt_trial == trials
mock_load.assert_called_once()

View File

@ -26,7 +26,7 @@ from tests.conftest import (log_has, log_has_re,
@pytest.fixture(scope="function")
def all_conf():
config_file = Path(__file__).parents[2] / "config_full.json.example"
config_file = Path(__file__).parents[1] / "config_full.json.example"
print(config_file)
conf = load_config_file(str(config_file))
return conf

View File

@ -10,9 +10,9 @@ from freqtrade.configuration import Arguments
from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.main import main
from freqtrade.state import State
from tests.conftest import (log_has, patch_exchange,
patched_configuration_load_config_file)
from freqtrade.worker import Worker
from tests.conftest import (log_has, patch_exchange,
patched_configuration_load_config_file)
def test_parse_args_backtesting(mocker) -> None: