From 09ec00888f7bb3ab359b35422bb850b7b3b2d870 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 15 Aug 2023 16:53:21 +0200 Subject: [PATCH] Don't use global variable in test --- tests/optimize/test_backtesting.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index f0bd18768..c6e01f0ad 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -1122,10 +1122,10 @@ def test_backtest_dataprovider_analyzed_df(default_conf, fee, mocker, testdatadi processed = backtesting.strategy.advise_all_indicators(data) min_date, max_date = get_timerange(processed) - global count count = 0 def tmp_confirm_entry(pair, current_time, **kwargs): + nonlocal count dp = backtesting.strategy.dp df, _ = dp.get_analyzed_dataframe(pair, backtesting.strategy.timeframe) current_candle = df.iloc[-1].squeeze() @@ -1135,8 +1135,7 @@ def test_backtest_dataprovider_analyzed_df(default_conf, fee, mocker, testdatadi assert candle_date == current_time # These asserts don't properly raise as they are nested, # therefore we increment count and assert for that. - global count - count = count + 1 + count += 1 backtesting.strategy.confirm_trade_entry = tmp_confirm_entry backtesting.backtest(