Fix broken tests

This commit is contained in:
Matthias 2022-10-14 14:59:55 +00:00
parent 9d4ba767c4
commit 4a8cb3359b
5 changed files with 10 additions and 12 deletions

View File

@ -204,8 +204,8 @@ class IResolver:
def _build_rel_location(cls, directory: Path, entry: Path) -> str: def _build_rel_location(cls, directory: Path, entry: Path) -> str:
builtin = cls.initial_search_path == directory builtin = cls.initial_search_path == directory
return f"<builtin>/{entry.relative_to(directory)}" if builtin else entry.relative_to( return f"<builtin>/{entry.relative_to(directory)}" if builtin else str(
directory) entry.relative_to(directory))
@classmethod @classmethod
def _search_all_objects( def _search_all_objects(

View File

@ -272,7 +272,7 @@ class StrategyResolver(IResolver):
def build_search_paths(cls, config: Config, user_subdir: Optional[str] = None, def build_search_paths(cls, config: Config, user_subdir: Optional[str] = None,
extra_dirs: List[str] = []) -> List[Path]: extra_dirs: List[str] = []) -> List[Path]:
if 'strategy_path' in config: if 'strategy_path' in config and config['strategy_path'] not in extra_dirs:
extra_dirs = [config['strategy_path']] + extra_dirs extra_dirs = [config['strategy_path']] + extra_dirs
return super().build_search_paths(config, user_subdir, extra_dirs) return super().build_search_paths(config, user_subdir, extra_dirs)

View File

@ -1,13 +1,11 @@
import logging import logging
from copy import deepcopy from copy import deepcopy
from pathlib import Path
from typing import List, Optional from typing import List, Optional
from fastapi import APIRouter, Depends, Query from fastapi import APIRouter, Depends, Query
from fastapi.exceptions import HTTPException from fastapi.exceptions import HTTPException
from freqtrade import __version__ from freqtrade import __version__
from freqtrade.constants import USERPATH_STRATEGIES
from freqtrade.data.history import get_datahandler from freqtrade.data.history import get_datahandler
from freqtrade.enums import CandleType, TradingMode from freqtrade.enums import CandleType, TradingMode
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException

View File

@ -1443,8 +1443,9 @@ def test_api_plot_config(botclient):
assert isinstance(rc.json()['subplots'], dict) assert isinstance(rc.json()['subplots'], dict)
def test_api_strategies(botclient): def test_api_strategies(botclient, tmpdir):
ftbot, client = botclient ftbot, client = botclient
ftbot.config['user_data_dir'] = Path(tmpdir)
rc = client_get(client, f"{BASE_URI}/strategies") rc = client_get(client, f"{BASE_URI}/strategies")

View File

@ -77,10 +77,9 @@ def test_load_strategy_base64(dataframe_1m, caplog, default_conf):
def test_load_strategy_invalid_directory(caplog, default_conf): def test_load_strategy_invalid_directory(caplog, default_conf):
default_conf['strategy'] = 'StrategyTestV3'
extra_dir = Path.cwd() / 'some/path' extra_dir = Path.cwd() / 'some/path'
with pytest.raises(OperationalException): with pytest.raises(OperationalException, match=r"Impossible to load Strategy.*"):
StrategyResolver._load_strategy(CURRENT_TEST_STRATEGY, config=default_conf, StrategyResolver._load_strategy('StrategyTestV333', config=default_conf,
extra_dir=extra_dir) extra_dir=extra_dir)
assert log_has_re(r'Path .*' + r'some.*path.*' + r'.* does not exist', caplog) assert log_has_re(r'Path .*' + r'some.*path.*' + r'.* does not exist', caplog)
@ -102,8 +101,8 @@ def test_load_strategy_noname(default_conf):
StrategyResolver.load_strategy(default_conf) StrategyResolver.load_strategy(default_conf)
@pytest.mark.filterwarnings("ignore:deprecated") @ pytest.mark.filterwarnings("ignore:deprecated")
@pytest.mark.parametrize('strategy_name', ['StrategyTestV2']) @ pytest.mark.parametrize('strategy_name', ['StrategyTestV2'])
def test_strategy_pre_v3(dataframe_1m, default_conf, strategy_name): def test_strategy_pre_v3(dataframe_1m, default_conf, strategy_name):
default_conf.update({'strategy': strategy_name}) default_conf.update({'strategy': strategy_name})
@ -349,7 +348,7 @@ def test_strategy_override_use_exit_profit_only(caplog, default_conf):
assert log_has("Override strategy 'exit_profit_only' with value in config file: True.", caplog) assert log_has("Override strategy 'exit_profit_only' with value in config file: True.", caplog)
@pytest.mark.filterwarnings("ignore:deprecated") @ pytest.mark.filterwarnings("ignore:deprecated")
def test_missing_implements(default_conf, caplog): def test_missing_implements(default_conf, caplog):
default_location = Path(__file__).parent / "strats" default_location = Path(__file__).parent / "strats"