Fixturize fee MagicMock object in tests
This commit is contained in:
@@ -505,11 +505,8 @@ def test_processed(init_backtesting) -> None:
|
||||
assert col in cols
|
||||
|
||||
|
||||
def test_backtest_pricecontours(init_backtesting, default_conf, mocker) -> None:
|
||||
mocker.patch(
|
||||
'freqtrade.optimize.backtesting.exchange.get_fee',
|
||||
MagicMock(return_value=0.0025)
|
||||
)
|
||||
def test_backtest_pricecontours(init_backtesting, default_conf, fee, mocker) -> None:
|
||||
mocker.patch('freqtrade.optimize.backtesting.exchange.get_fee', fee)
|
||||
tests = [['raise', 17], ['lower', 0], ['sine', 17]]
|
||||
for [contour, numres] in tests:
|
||||
simple_backtest(default_conf, contour, numres)
|
||||
@@ -549,23 +546,17 @@ def test_backtest_only_sell(init_backtesting, default_conf):
|
||||
assert results.empty
|
||||
|
||||
|
||||
def test_backtest_alternate_buy_sell(init_backtesting, default_conf, mocker):
|
||||
mocker.patch(
|
||||
'freqtrade.optimize.backtesting.exchange.get_fee',
|
||||
MagicMock(return_value=0.0025)
|
||||
)
|
||||
def test_backtest_alternate_buy_sell(init_backtesting, default_conf, fee, mocker):
|
||||
mocker.patch('freqtrade.optimize.backtesting.exchange.get_fee', fee)
|
||||
backtest_conf = _make_backtest_conf(conf=default_conf, pair='UNITTEST/BTC')
|
||||
results = _run_backtest_1(_trend_alternate, backtest_conf)
|
||||
assert len(results) == 3
|
||||
|
||||
|
||||
def test_backtest_record(init_backtesting, default_conf, mocker):
|
||||
def test_backtest_record(init_backtesting, default_conf, fee, mocker):
|
||||
names = []
|
||||
records = []
|
||||
mocker.patch(
|
||||
'freqtrade.optimize.backtesting.exchange.get_fee',
|
||||
MagicMock(return_value=0.0025)
|
||||
)
|
||||
mocker.patch('freqtrade.optimize.backtesting.exchange.get_fee', fee)
|
||||
mocker.patch(
|
||||
'freqtrade.optimize.backtesting.file_dump_json',
|
||||
new=lambda n, r: (names.append(n), records.append(r))
|
||||
|
Reference in New Issue
Block a user