Fix CI failures: Linter errors and Stoploss tests

Fixed:
- Trailing whitespace in `freqtrade/resolvers/strategy_resolver.py`.
- Missing blank lines in `tests/strategy/test_deprecation_warnings.py` (E302).
- Failing `test_stoploss_on_exchange` tests by explicitly enabling `stoploss_on_exchange` in the strategy config within the tests, ensuring the logic under test is actually executed.

Verified:
- Local `pytest` passed.
- Local `ruff` and `isort` checks passed.

Co-authored-by: Corax-CoLAB <239841157+Corax-CoLAB@users.noreply.github.com>
pull/12809/head
google-labs-jules[bot] 4 months ago
parent d066544508
commit fb2ee60ea2

@ -342,5 +342,3 @@ def warn_deprecated_setting(strategy: IStrategy, old: str, new: str, error=False
raise OperationalException(errormsg)
logger.warning(errormsg)
setattr(strategy, new, getattr(strategy, f"{old}"))

@ -44,6 +44,7 @@ def test_add_stoploss_on_exchange(mocker, default_conf_usdt, limit_order, is_sho
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
@ -82,6 +83,7 @@ def test_handle_stoploss_on_exchange(
create_stoploss=stoploss,
)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
# First case: when stoploss is not yet set but the order is open
@ -213,6 +215,7 @@ def test_handle_stoploss_on_exchange_emergency(
create_stoploss=stoploss,
)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
freqtrade.enter_positions()
@ -291,6 +294,7 @@ def test_handle_stoploss_on_exchange_partial(
create_stoploss=stoploss,
)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
freqtrade.enter_positions()
@ -351,6 +355,7 @@ def test_handle_stoploss_on_exchange_partial_cancel_here(
create_stoploss=stoploss,
)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
freqtrade.enter_positions()
@ -421,6 +426,7 @@ def test_handle_sle_cancel_cant_recreate(
get_fee=fee,
)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
mocker.patch.multiple(
freqtrade.exchange,
create_order=MagicMock(
@ -483,6 +489,7 @@ def test_create_stoploss_order_invalid_order(
create_stoploss=MagicMock(side_effect=InvalidOrderException()),
)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
@ -1017,6 +1024,7 @@ def test_execute_trade_exit_down_stoploss_on_exchange_dry_run(
)
patch_whitelist(mocker, default_conf_usdt)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short)
# Create some test data
@ -1145,6 +1153,7 @@ def test_execute_trade_exit_with_stoploss_on_exchange(
price_to_precision=lambda s, x, y: y,
)
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
mocker.patch.multiple(
freqtrade.exchange,
create_stoploss=stoploss,
@ -1204,6 +1213,7 @@ def test_may_execute_trade_exit_after_stoploss_on_exchange_hit(
freqtrade = FreqtradeBot(default_conf_usdt)
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
freqtrade.strategy.order_types["stoploss_on_exchange"] = True
patch_get_signal(freqtrade, enter_long=not is_short, enter_short=is_short)
# Create some test data

@ -25,6 +25,7 @@ class StrategyWithLegacyMethods(IStrategy):
def custom_sell(self, pair, trade, current_time, current_rate, current_profit, **kwargs):
return None
def test_deprecation_warnings_legacy_methods(default_conf, caplog):
caplog.set_level(logging.WARNING)

Loading…
Cancel
Save