Skip to content

Commit

Permalink
Remove unnecessary mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Dec 28, 2019
1 parent aa39f21 commit 80dbba1
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions tests/optimize/test_backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ def simple_backtest(config, contour, num_results, mocker, testdatadir) -> None:
assert len(results) == num_results


# use for mock ccxt.fetch_ohlvc'
def _load_pair_as_ticks(pair, tickfreq):
ticks = history.load_tickerdata_file(None, timeframe=tickfreq, pair=pair)
ticks = ticks[-201:]
return ticks


# FIX: fixturize this?
def _make_backtest_conf(mocker, datadir, conf=None, pair='UNITTEST/BTC', record=None):
data = history.load_data(datadir=datadir, timeframe='1m', pairs=[pair])
Expand Down Expand Up @@ -795,13 +788,7 @@ def test_backtest_record(default_conf, fee, mocker):
def test_backtest_start_timerange(default_conf, mocker, caplog, testdatadir):
default_conf['exchange']['pair_whitelist'] = ['UNITTEST/BTC']

async def load_pairs(pair, timeframe, since):
return _load_pair_as_ticks(pair, timeframe)

api_mock = MagicMock()
api_mock.fetch_ohlcv = load_pairs

patch_exchange(mocker, api_mock)
patch_exchange(mocker)
mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest', MagicMock())
mocker.patch('freqtrade.optimize.backtesting.Backtesting._generate_text_table', MagicMock())
patched_configuration_load_config_file(mocker, default_conf)
Expand Down Expand Up @@ -840,12 +827,7 @@ async def load_pairs(pair, timeframe, since):
def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir):
default_conf['exchange']['pair_whitelist'] = ['UNITTEST/BTC']

async def load_pairs(pair, timeframe, since):
return _load_pair_as_ticks(pair, timeframe)
api_mock = MagicMock()
api_mock.fetch_ohlcv = load_pairs

patch_exchange(mocker, api_mock)
patch_exchange(mocker)
backtestmock = MagicMock()
mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest', backtestmock)
gen_table_mock = MagicMock()
Expand Down

0 comments on commit 80dbba1

Please sign in to comment.