Auto-mock user_dir to tmpdir

This will avoid depending on the user directory being present for tests
This commit is contained in:
Matthias
2023-05-11 07:05:43 +02:00
parent deeca484d8
commit 7e023419de
2 changed files with 8 additions and 2 deletions

View File

@@ -411,6 +411,12 @@ def patch_gc(mocker) -> None:
mocker.patch("freqtrade.main.gc_set_threshold")
@pytest.fixture(autouse=True)
def patched_user_dir(mocker, tmpdir) -> None:
mocker.patch('freqtrade.configuration.configuration.create_userdata_dir',
return_value=Path(tmpdir) / "user_data")
@pytest.fixture(autouse=True)
def patch_coingekko(mocker) -> None:
"""

View File

@@ -1271,7 +1271,7 @@ def test_pairlist_resolving_with_config_pl_not_exists(mocker, default_conf):
configuration.get_config()
def test_pairlist_resolving_fallback(mocker):
def test_pairlist_resolving_fallback(mocker, tmpdir):
mocker.patch.object(Path, "exists", MagicMock(return_value=True))
mocker.patch.object(Path, "open", MagicMock(return_value=MagicMock()))
mocker.patch("freqtrade.configuration.configuration.load_file",
@@ -1290,7 +1290,7 @@ def test_pairlist_resolving_fallback(mocker):
assert config['pairs'] == ['ETH/BTC', 'XRP/BTC']
assert config['exchange']['name'] == 'binance'
assert config['datadir'] == Path.cwd() / "user_data/data/binance"
assert config['datadir'] == Path(tmpdir) / "user_data/data/binance"
@pytest.mark.parametrize("setting", [