From 682daa4e941abf2235e60d9ecd1ad029eec5d3c4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 26 May 2022 18:05:40 +0200 Subject: [PATCH] Reset logging mixin to avoid random test failure --- freqtrade/exchange/common.py | 8 ++++++++ tests/exchange/test_exchange.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/freqtrade/exchange/common.py b/freqtrade/exchange/common.py index a9f03ba1a..841f45cd0 100644 --- a/freqtrade/exchange/common.py +++ b/freqtrade/exchange/common.py @@ -12,6 +12,14 @@ logger = logging.getLogger(__name__) __logging_mixin = None +def _reset_logging_mixin(): + """ + Reset global logging mixin - used in tests only. + """ + global __logging_mixin + __logging_mixin = LoggingMixin(logger) + + def _get_logging_mixin(): # Logging-mixin to cache kucoin responses # Only to be used in retrier diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index b19c59e50..9da2dbc11 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -2155,6 +2155,8 @@ async def test__async_get_candle_history(default_conf, mocker, caplog, exchange_ @pytest.mark.asyncio async def test__async_kucoin_get_candle_history(default_conf, mocker, caplog): + from freqtrade.exchange.common import _reset_logging_mixin + _reset_logging_mixin() caplog.set_level(logging.INFO) api_mock = MagicMock() api_mock.fetch_ohlcv = MagicMock(side_effect=ccxt.DDoSProtection(