From 1634297685489bd1dd47802801bef7daae1a7238 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 18 Feb 2020 20:12:10 +0100 Subject: [PATCH] Move strategies to test subfolder --- tests/commands/test_commands.py | 4 ++-- tests/conftest.py | 1 + .../strategy/strats}/default_strategy.py | 0 tests/strategy/{ => strats}/failing_strategy.py | 0 tests/strategy/{ => strats}/legacy_strategy.py | 0 tests/strategy/test_default_strategy.py | 2 +- tests/strategy/test_interface.py | 2 +- tests/strategy/test_strategy.py | 14 +++++++------- 8 files changed, 12 insertions(+), 11 deletions(-) rename {freqtrade/strategy => tests/strategy/strats}/default_strategy.py (100%) rename tests/strategy/{ => strats}/failing_strategy.py (100%) rename tests/strategy/{ => strats}/legacy_strategy.py (100%) diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index ee1db5db5..55bd7306d 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -640,7 +640,7 @@ def test_start_list_strategies(mocker, caplog, capsys): args = [ "list-strategies", "--strategy-path", - str(Path(__file__).parent.parent / "strategy"), + str(Path(__file__).parent.parent / "strategy" / "strats"), "-1" ] pargs = get_args(args) @@ -655,7 +655,7 @@ def test_start_list_strategies(mocker, caplog, capsys): args = [ "list-strategies", "--strategy-path", - str(Path(__file__).parent.parent / "strategy"), + str(Path(__file__).parent.parent / "strategy" / "strats"), ] pargs = get_args(args) # pargs['config'] = None diff --git a/tests/conftest.py b/tests/conftest.py index e897dbccd..acb730330 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -257,6 +257,7 @@ def default_conf(testdatadir): "db_url": "sqlite://", "user_data_dir": Path("user_data"), "verbosity": 3, + "strategy_path": str(Path(__file__).parent / "strategy" / "strats"), "strategy": "DefaultStrategy" } return configuration diff --git a/freqtrade/strategy/default_strategy.py b/tests/strategy/strats/default_strategy.py similarity index 100% rename from freqtrade/strategy/default_strategy.py rename to tests/strategy/strats/default_strategy.py diff --git a/tests/strategy/failing_strategy.py b/tests/strategy/strats/failing_strategy.py similarity index 100% rename from tests/strategy/failing_strategy.py rename to tests/strategy/strats/failing_strategy.py diff --git a/tests/strategy/legacy_strategy.py b/tests/strategy/strats/legacy_strategy.py similarity index 100% rename from tests/strategy/legacy_strategy.py rename to tests/strategy/strats/legacy_strategy.py diff --git a/tests/strategy/test_default_strategy.py b/tests/strategy/test_default_strategy.py index 17d6b8ee0..0b8ea9f85 100644 --- a/tests/strategy/test_default_strategy.py +++ b/tests/strategy/test_default_strategy.py @@ -1,6 +1,6 @@ from pandas import DataFrame -from freqtrade.strategy.default_strategy import DefaultStrategy +from .strats.default_strategy import DefaultStrategy def test_default_strategy_structure(): diff --git a/tests/strategy/test_interface.py b/tests/strategy/test_interface.py index a28519383..def64425e 100644 --- a/tests/strategy/test_interface.py +++ b/tests/strategy/test_interface.py @@ -11,7 +11,7 @@ from freqtrade.data.converter import parse_ticker_dataframe from freqtrade.data.history import load_tickerdata_file from freqtrade.persistence import Trade 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 # Avoid to reinit the same object again and again diff --git a/tests/strategy/test_strategy.py b/tests/strategy/test_strategy.py index 379260599..5c6de8260 100644 --- a/tests/strategy/test_strategy.py +++ b/tests/strategy/test_strategy.py @@ -31,21 +31,21 @@ def test_search_strategy(): 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) assert isinstance(strategies, list) - assert len(strategies) == 3 + assert len(strategies) == 2 assert isinstance(strategies[0], dict) 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) assert isinstance(strategies, list) - assert len(strategies) == 4 + assert len(strategies) == 3 # with enum_failed=True search_all_objects() shall find 3 good strategies # 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 @@ -326,7 +326,7 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf): @pytest.mark.filterwarnings("ignore:deprecated") 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', 'strategy_path': default_location}) strategy = StrategyResolver.load_strategy(default_conf) @@ -360,7 +360,7 @@ def test_deprecate_populate_indicators(result, default_conf): @pytest.mark.filterwarnings("ignore:deprecated") 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', 'strategy_path': default_location}) strategy = StrategyResolver.load_strategy(default_conf)