mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
use tmp_path instead of Path(tmpdir)
This commit is contained in:
@@ -413,8 +413,8 @@ def patch_gc(mocker) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def user_dir(mocker, tmpdir) -> Path:
|
def user_dir(mocker, tmp_path) -> Path:
|
||||||
user_dir = Path(tmpdir) / "user_data"
|
user_dir = tmp_path / "user_data"
|
||||||
mocker.patch('freqtrade.configuration.configuration.create_userdata_dir',
|
mocker.patch('freqtrade.configuration.configuration.create_userdata_dir',
|
||||||
return_value=user_dir)
|
return_value=user_dir)
|
||||||
return user_dir
|
return user_dir
|
||||||
|
|||||||
@@ -1023,15 +1023,15 @@ def test_stake_amount_unlimited_max_open_trades(mocker, hyperopt_conf, tmpdir, f
|
|||||||
assert hyperopt.backtesting.strategy.max_open_trades == 1
|
assert hyperopt.backtesting.strategy.max_open_trades == 1
|
||||||
|
|
||||||
|
|
||||||
def test_max_open_trades_dump(mocker, hyperopt_conf, tmpdir, fee, capsys) -> None:
|
def test_max_open_trades_dump(mocker, hyperopt_conf, tmp_path, fee, capsys) -> None:
|
||||||
# This test is to ensure that after hyperopting, max_open_trades is never
|
# This test is to ensure that after hyperopting, max_open_trades is never
|
||||||
# saved as inf in the output json params
|
# saved as inf in the output json params
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
mocker.patch(f'{EXMS}.get_fee', fee)
|
mocker.patch(f'{EXMS}.get_fee', fee)
|
||||||
(Path(tmpdir) / 'hyperopt_results').mkdir(parents=True)
|
(tmp_path / 'hyperopt_results').mkdir(parents=True)
|
||||||
hyperopt_conf.update({
|
hyperopt_conf.update({
|
||||||
'strategy': 'HyperoptableStrategy',
|
'strategy': 'HyperoptableStrategy',
|
||||||
'user_data_dir': Path(tmpdir),
|
'user_data_dir': tmp_path,
|
||||||
'hyperopt_random_state': 42,
|
'hyperopt_random_state': 42,
|
||||||
'spaces': ['trades'],
|
'spaces': ['trades'],
|
||||||
})
|
})
|
||||||
@@ -1069,16 +1069,16 @@ def test_max_open_trades_dump(mocker, hyperopt_conf, tmpdir, fee, capsys) -> Non
|
|||||||
assert '"max_open_trades":-1' in out
|
assert '"max_open_trades":-1' in out
|
||||||
|
|
||||||
|
|
||||||
def test_max_open_trades_consistency(mocker, hyperopt_conf, tmpdir, fee) -> None:
|
def test_max_open_trades_consistency(mocker, hyperopt_conf, tmp_path, fee) -> None:
|
||||||
# This test is to ensure that max_open_trades is the same across all functions needing it
|
# This test is to ensure that max_open_trades is the same across all functions needing it
|
||||||
# after it has been changed from the hyperopt
|
# after it has been changed from the hyperopt
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
mocker.patch(f'{EXMS}.get_fee', return_value=0)
|
mocker.patch(f'{EXMS}.get_fee', return_value=0)
|
||||||
|
|
||||||
(Path(tmpdir) / 'hyperopt_results').mkdir(parents=True)
|
(tmp_path / 'hyperopt_results').mkdir(parents=True)
|
||||||
hyperopt_conf.update({
|
hyperopt_conf.update({
|
||||||
'strategy': 'HyperoptableStrategy',
|
'strategy': 'HyperoptableStrategy',
|
||||||
'user_data_dir': Path(tmpdir),
|
'user_data_dir': tmp_path,
|
||||||
'hyperopt_random_state': 42,
|
'hyperopt_random_state': 42,
|
||||||
'spaces': ['trades'],
|
'spaces': ['trades'],
|
||||||
'stake_amount': 'unlimited',
|
'stake_amount': 'unlimited',
|
||||||
|
|||||||
Reference in New Issue
Block a user