Add additional test
This commit is contained in:
parent
6c55b40fe0
commit
8f7e113d79
@ -29,8 +29,11 @@ def log_config_error_range(path: str, errmsg: str) -> str:
|
||||
# Fetch an offset of 80 characters around the error line
|
||||
subtext = text[offset-min(80, offset):offset+80]
|
||||
segments = subtext.split('\n')
|
||||
# Remove first and last lines, to avoid odd truncations
|
||||
return '\n'.join(segments[1:-1])
|
||||
if len(segments) > 3:
|
||||
# Remove first and last lines, to avoid odd truncations
|
||||
return '\n'.join(segments[1:-1])
|
||||
else:
|
||||
return subtext
|
||||
|
||||
|
||||
def load_config_file(path: str) -> Dict[str, Any]:
|
||||
|
@ -18,7 +18,7 @@ from freqtrade.configuration.config_validation import validate_config_schema
|
||||
from freqtrade.configuration.deprecated_settings import (
|
||||
check_conflicting_settings, process_deprecated_setting,
|
||||
process_temporary_deprecated_settings)
|
||||
from freqtrade.configuration.load_config import load_config_file
|
||||
from freqtrade.configuration.load_config import load_config_file, log_config_error_range
|
||||
from freqtrade.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.loggers import _set_loggers, setup_logging
|
||||
@ -77,6 +77,19 @@ def test_load_config_file_error(default_conf, mocker, caplog) -> None:
|
||||
load_config_file('somefile')
|
||||
|
||||
|
||||
def test_load_config_file_error_range(default_conf, mocker, caplog) -> None:
|
||||
del default_conf['user_data_dir']
|
||||
filedata = json.dumps(default_conf).replace(
|
||||
'"stake_amount": 0.001,', '"stake_amount": .001,')
|
||||
mocker.patch.object(Path, "read_text", MagicMock(return_value=filedata))
|
||||
|
||||
x = log_config_error_range('somefile', 'Parse error at offset 64: Invalid value.')
|
||||
assert isinstance(x, str)
|
||||
assert (x == '{"max_open_trades": 1, "stake_currency": "BTC", '
|
||||
'"stake_amount": .001, "fiat_display_currency": "USD", '
|
||||
'"ticker_interval": "5m", "dry_run": true, ')
|
||||
|
||||
|
||||
def test__args_to_config(caplog):
|
||||
|
||||
arg_list = ['trade', '--strategy-path', 'TestTest']
|
||||
|
Loading…
Reference in New Issue
Block a user