mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Adjust test to pathlib
This commit is contained in:
parent
21aba1620c
commit
6c02cc5993
|
@ -64,7 +64,7 @@ def trim_tickerlist(tickerlist: List[Dict], timerange: TimeRange) -> List[Dict]:
|
|||
|
||||
|
||||
def load_tickerdata_file(
|
||||
datadir: Path, pair: str,
|
||||
datadir: Optional[Path], pair: str,
|
||||
ticker_interval: str,
|
||||
timerange: Optional[TimeRange] = None) -> Optional[List[Dict]]:
|
||||
"""
|
||||
|
|
|
@ -100,7 +100,7 @@ class Edge():
|
|||
logger.info('Using local backtesting data (using whitelist in given config) ...')
|
||||
|
||||
data = history.load_data(
|
||||
Path(self.config.get('datadir')) if self.config.get('datadir') else None,
|
||||
Path(self.config['datadir']) if self.config.get('datadir') else None,
|
||||
pairs=pairs,
|
||||
ticker_interval=self.ticker_interval,
|
||||
refresh_pairs=self._refresh_pairs,
|
||||
|
|
|
@ -370,7 +370,7 @@ class Backtesting(object):
|
|||
timerange = Arguments.parse_timerange(None if self.config.get(
|
||||
'timerange') is None else str(self.config.get('timerange')))
|
||||
data = history.load_data(
|
||||
Path(self.config.get('datadir')) if self.config.get('datadir') else None,
|
||||
Path(self.config['datadir']) if self.config.get('datadir') else None,
|
||||
pairs=pairs,
|
||||
ticker_interval=self.ticker_interval,
|
||||
refresh_pairs=self.config.get('refresh_pairs', False),
|
||||
|
|
|
@ -241,7 +241,7 @@ class Hyperopt(Backtesting):
|
|||
timerange = Arguments.parse_timerange(None if self.config.get(
|
||||
'timerange') is None else str(self.config.get('timerange')))
|
||||
data = load_data(
|
||||
datadir=Path(self.config.get('datadir')) if self.config.get('datadir') else None,
|
||||
datadir=Path(self.config['datadir']) if self.config.get('datadir') else None,
|
||||
pairs=self.config['exchange']['pair_whitelist'],
|
||||
ticker_interval=self.ticker_interval,
|
||||
timerange=timerange
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import uuid
|
||||
from shutil import copyfile
|
||||
|
||||
|
@ -116,7 +117,7 @@ def test_load_data_with_new_pair_1min(ticker_history_list, mocker, caplog, defau
|
|||
|
||||
|
||||
def test_testdata_path() -> None:
|
||||
assert os.path.join('freqtrade', 'tests', 'testdata') in make_testdata_path(None)
|
||||
assert str(Path('freqtrade') / 'tests' / 'testdata') in str(make_testdata_path(None))
|
||||
|
||||
|
||||
def test_download_pairs(ticker_history_list, mocker, default_conf) -> None:
|
||||
|
@ -160,10 +161,10 @@ def test_download_pairs(ticker_history_list, mocker, default_conf) -> None:
|
|||
|
||||
|
||||
def test_load_cached_data_for_updating(mocker) -> None:
|
||||
datadir = os.path.join(os.path.dirname(__file__), '..', 'testdata')
|
||||
datadir = Path(__file__).parent.parent.joinpath('testdata')
|
||||
|
||||
test_data = None
|
||||
test_filename = os.path.join(datadir, 'UNITTEST_BTC-1m.json')
|
||||
test_filename = datadir.joinpath('UNITTEST_BTC-1m.json')
|
||||
with open(test_filename, "rt") as file:
|
||||
test_data = json.load(file)
|
||||
|
||||
|
@ -238,7 +239,7 @@ def test_load_cached_data_for_updating(mocker) -> None:
|
|||
# no datafile exist
|
||||
# should return timestamp start time
|
||||
timerange = TimeRange('date', None, now_ts - 10000, 0)
|
||||
data, start_ts = load_cached_data_for_updating(test_filename + 'unexist',
|
||||
data, start_ts = load_cached_data_for_updating(test_filename.with_name('unexist'),
|
||||
'1m',
|
||||
timerange)
|
||||
assert data == []
|
||||
|
@ -247,7 +248,7 @@ def test_load_cached_data_for_updating(mocker) -> None:
|
|||
# same with 'line' timeframe
|
||||
num_lines = 30
|
||||
timerange = TimeRange(None, 'line', 0, -num_lines)
|
||||
data, start_ts = load_cached_data_for_updating(test_filename + 'unexist',
|
||||
data, start_ts = load_cached_data_for_updating(test_filename.with_name('unexist'),
|
||||
'1m',
|
||||
timerange)
|
||||
assert data == []
|
||||
|
@ -255,7 +256,7 @@ def test_load_cached_data_for_updating(mocker) -> None:
|
|||
|
||||
# no datafile exist, no timeframe is set
|
||||
# should return an empty array and None
|
||||
data, start_ts = load_cached_data_for_updating(test_filename + 'unexist',
|
||||
data, start_ts = load_cached_data_for_updating(test_filename.with_name('unexist'),
|
||||
'1m',
|
||||
None)
|
||||
assert data == []
|
||||
|
|
Loading…
Reference in New Issue
Block a user