Skip to content

Commit

Permalink
Fix paths in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Sep 8, 2019
1 parent f2cbc5f commit 9513115
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/data/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 9 additions & 10 deletions tests/optimize/test_hyperopt.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
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:
Expand Down

0 comments on commit 9513115

Please sign in to comment.