Move strategies to test subfolder

This commit is contained in:
Matthias 2020-02-18 20:12:10 +01:00
parent 16cbd441ce
commit 1634297685
8 changed files with 12 additions and 11 deletions

View File

@ -640,7 +640,7 @@ def test_start_list_strategies(mocker, caplog, capsys):
args = [ args = [
"list-strategies", "list-strategies",
"--strategy-path", "--strategy-path",
str(Path(__file__).parent.parent / "strategy"), str(Path(__file__).parent.parent / "strategy" / "strats"),
"-1" "-1"
] ]
pargs = get_args(args) pargs = get_args(args)
@ -655,7 +655,7 @@ def test_start_list_strategies(mocker, caplog, capsys):
args = [ args = [
"list-strategies", "list-strategies",
"--strategy-path", "--strategy-path",
str(Path(__file__).parent.parent / "strategy"), str(Path(__file__).parent.parent / "strategy" / "strats"),
] ]
pargs = get_args(args) pargs = get_args(args)
# pargs['config'] = None # pargs['config'] = None

View File

@ -257,6 +257,7 @@ def default_conf(testdatadir):
"db_url": "sqlite://", "db_url": "sqlite://",
"user_data_dir": Path("user_data"), "user_data_dir": Path("user_data"),
"verbosity": 3, "verbosity": 3,
"strategy_path": str(Path(__file__).parent / "strategy" / "strats"),
"strategy": "DefaultStrategy" "strategy": "DefaultStrategy"
} }
return configuration return configuration

View File

@ -1,6 +1,6 @@
from pandas import DataFrame from pandas import DataFrame
from freqtrade.strategy.default_strategy import DefaultStrategy from .strats.default_strategy import DefaultStrategy
def test_default_strategy_structure(): def test_default_strategy_structure():

View File

@ -11,7 +11,7 @@ from freqtrade.data.converter import parse_ticker_dataframe
from freqtrade.data.history import load_tickerdata_file from freqtrade.data.history import load_tickerdata_file
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.resolvers import StrategyResolver from freqtrade.resolvers import StrategyResolver
from freqtrade.strategy.default_strategy import DefaultStrategy from .strats.default_strategy import DefaultStrategy
from tests.conftest import get_patched_exchange, log_has from tests.conftest import get_patched_exchange, log_has
# Avoid to reinit the same object again and again # Avoid to reinit the same object again and again

View File

@ -31,21 +31,21 @@ def test_search_strategy():
def test_search_all_strategies_no_failed(): def test_search_all_strategies_no_failed():
directory = Path(__file__).parent directory = Path(__file__).parent / "strats"
strategies = StrategyResolver.search_all_objects(directory, enum_failed=False) strategies = StrategyResolver.search_all_objects(directory, enum_failed=False)
assert isinstance(strategies, list) assert isinstance(strategies, list)
assert len(strategies) == 3 assert len(strategies) == 2
assert isinstance(strategies[0], dict) assert isinstance(strategies[0], dict)
def test_search_all_strategies_with_failed(): def test_search_all_strategies_with_failed():
directory = Path(__file__).parent directory = Path(__file__).parent / "strats"
strategies = StrategyResolver.search_all_objects(directory, enum_failed=True) strategies = StrategyResolver.search_all_objects(directory, enum_failed=True)
assert isinstance(strategies, list) assert isinstance(strategies, list)
assert len(strategies) == 4 assert len(strategies) == 3
# with enum_failed=True search_all_objects() shall find 3 good strategies # with enum_failed=True search_all_objects() shall find 3 good strategies
# and 1 which fails to load # and 1 which fails to load
assert len([x for x in strategies if x['class'] is not None]) == 3 assert len([x for x in strategies if x['class'] is not None]) == 2
assert len([x for x in strategies if x['class'] is None]) == 1 assert len([x for x in strategies if x['class'] is None]) == 1
@ -326,7 +326,7 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
@pytest.mark.filterwarnings("ignore:deprecated") @pytest.mark.filterwarnings("ignore:deprecated")
def test_deprecate_populate_indicators(result, default_conf): def test_deprecate_populate_indicators(result, default_conf):
default_location = path.join(path.dirname(path.realpath(__file__))) default_location = Path(__file__).parent / "strats"
default_conf.update({'strategy': 'TestStrategyLegacy', default_conf.update({'strategy': 'TestStrategyLegacy',
'strategy_path': default_location}) 'strategy_path': default_location})
strategy = StrategyResolver.load_strategy(default_conf) strategy = StrategyResolver.load_strategy(default_conf)
@ -360,7 +360,7 @@ def test_deprecate_populate_indicators(result, default_conf):
@pytest.mark.filterwarnings("ignore:deprecated") @pytest.mark.filterwarnings("ignore:deprecated")
def test_call_deprecated_function(result, monkeypatch, default_conf): def test_call_deprecated_function(result, monkeypatch, default_conf):
default_location = path.join(path.dirname(path.realpath(__file__))) default_location = Path(__file__).parent / "strats"
default_conf.update({'strategy': 'TestStrategyLegacy', default_conf.update({'strategy': 'TestStrategyLegacy',
'strategy_path': default_location}) 'strategy_path': default_location})
strategy = StrategyResolver.load_strategy(default_conf) strategy = StrategyResolver.load_strategy(default_conf)