Don't write to testdir, but to tempdir
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# pragma pylint: disable=missing-docstring, C0103
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -11,7 +13,7 @@ from freqtrade.data.converter import (convert_ohlcv_format, convert_trades_forma
|
||||
from freqtrade.data.history import (get_timerange, load_data, load_pair_history,
|
||||
validate_backtest_data)
|
||||
from tests.conftest import log_has, log_has_re
|
||||
from tests.data.test_history import _backup_file, _clean_test_file
|
||||
from tests.data.test_history import _clean_test_file
|
||||
|
||||
|
||||
def test_dataframe_correct_columns(result):
|
||||
@@ -251,17 +253,19 @@ def test_trades_dict_to_list(fetch_trades_result):
|
||||
assert t[6] == fetch_trades_result[i]['cost']
|
||||
|
||||
|
||||
def test_convert_trades_format(mocker, default_conf, testdatadir):
|
||||
files = [{'old': testdatadir / "XRP_ETH-trades.json.gz",
|
||||
'new': testdatadir / "XRP_ETH-trades.json"},
|
||||
{'old': testdatadir / "XRP_OLD-trades.json.gz",
|
||||
'new': testdatadir / "XRP_OLD-trades.json"},
|
||||
def test_convert_trades_format(default_conf, testdatadir, tmpdir):
|
||||
tmpdir1 = Path(tmpdir)
|
||||
files = [{'old': tmpdir1 / "XRP_ETH-trades.json.gz",
|
||||
'new': tmpdir1 / "XRP_ETH-trades.json"},
|
||||
{'old': tmpdir1 / "XRP_OLD-trades.json.gz",
|
||||
'new': tmpdir1 / "XRP_OLD-trades.json"},
|
||||
]
|
||||
for file in files:
|
||||
_backup_file(file['old'], copy_file=True)
|
||||
copyfile(testdatadir / file['old'].name, file['old'])
|
||||
# _backup_file(file['old'], copy_file=True)
|
||||
assert not file['new'].exists()
|
||||
|
||||
default_conf['datadir'] = testdatadir
|
||||
default_conf['datadir'] = tmpdir1
|
||||
|
||||
convert_trades_format(default_conf, convert_from='jsongz',
|
||||
convert_to='json', erase=False)
|
||||
@@ -284,14 +288,20 @@ def test_convert_trades_format(mocker, default_conf, testdatadir):
|
||||
file['new'].unlink()
|
||||
|
||||
|
||||
def test_convert_ohlcv_format(mocker, default_conf, testdatadir):
|
||||
file1 = testdatadir / "XRP_ETH-5m.json"
|
||||
file1_new = testdatadir / "XRP_ETH-5m.json.gz"
|
||||
file2 = testdatadir / "XRP_ETH-1m.json"
|
||||
file2_new = testdatadir / "XRP_ETH-1m.json.gz"
|
||||
_backup_file(file1, copy_file=True)
|
||||
_backup_file(file2, copy_file=True)
|
||||
default_conf['datadir'] = testdatadir
|
||||
def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir):
|
||||
tmpdir1 = Path(tmpdir)
|
||||
|
||||
file1_orig = testdatadir / "XRP_ETH-5m.json"
|
||||
file1 = tmpdir1 / "XRP_ETH-5m.json"
|
||||
file1_new = tmpdir1 / "XRP_ETH-5m.json.gz"
|
||||
file2_orig = testdatadir / "XRP_ETH-1m.json"
|
||||
file2 = tmpdir1 / "XRP_ETH-1m.json"
|
||||
file2_new = tmpdir1 / "XRP_ETH-1m.json.gz"
|
||||
|
||||
copyfile(file1_orig, file1)
|
||||
copyfile(file2_orig, file2)
|
||||
|
||||
default_conf['datadir'] = tmpdir1
|
||||
default_conf['pairs'] = ['XRP_ETH']
|
||||
default_conf['timeframes'] = ['1m', '5m']
|
||||
|
||||
@@ -317,10 +327,3 @@ def test_convert_ohlcv_format(mocker, default_conf, testdatadir):
|
||||
assert file2.exists()
|
||||
assert not file1_new.exists()
|
||||
assert not file2_new.exists()
|
||||
|
||||
_clean_test_file(file1)
|
||||
_clean_test_file(file2)
|
||||
if file1_new.exists():
|
||||
file1_new.unlink()
|
||||
if file2_new.exists():
|
||||
file2_new.unlink()
|
||||
|
Reference in New Issue
Block a user