reuse same mock for get_ticker_history, just change return_value

This commit is contained in:
Janne Sinivirta 2017-10-30 22:06:09 +02:00
parent 8da55c3742
commit 7190226c84

View File

@ -44,13 +44,13 @@ def conf():
def backtest(conf, pairs, mocker):
trades = []
mocked_history = mocker.patch('freqtrade.analyze.get_ticker_history')
mocker.patch.dict('freqtrade.main._CONF', conf)
mocker.patch('arrow.utcnow', return_value=arrow.get('2017-08-20T14:50:00'))
for pair in pairs:
with open('freqtrade/tests/testdata/'+pair+'.json') as data_file:
data = json.load(data_file)
mocker.patch('freqtrade.analyze.get_ticker_history', return_value=data)
mocked_history.return_value = data
ticker = analyze_ticker(pair)[['close', 'date', 'buy']].copy()
# for each buy point
for row in ticker[ticker.buy == 1].itertuples(index=True):