diff --git a/tests/data/test_history.py b/tests/data/test_history.py index 857967f39..e747794e5 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -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: diff --git a/tests/optimize/test_hyperopt.py b/tests/optimize/test_hyperopt.py index eec9e7c19..900405f03 100644 --- a/tests/optimize/test_hyperopt.py +++ b/tests/optimize/test_hyperopt.py @@ -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() diff --git a/tests/test_configuration.py b/tests/test_configuration.py index e6532cecc..20ebda440 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -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 diff --git a/tests/test_main.py b/tests/test_main.py index d6fafe09b..eec81ee18 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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: