Fix bug in pairs fallback resolving

This commit is contained in:
Matthias 2019-08-17 07:05:42 +02:00
parent a53e9e3a98
commit 7a79b292e4
2 changed files with 20 additions and 1 deletions

View File

@ -380,7 +380,7 @@ class Configuration(object):
config['pairs'].sort()
return
if "config" in self.args:
if "config" in self.args and self.args.config:
logger.info("Using pairlist from configuration.")
config['pairs'] = config.get('exchange', {}).get('pair_whitelist')
else:
@ -388,3 +388,4 @@ class Configuration(object):
pairs_file = Path(config['datadir']) / "pairs.json"
if pairs_file.exists():
config['pairs'] = json_load(pairs_file)
config['pairs'].sort()

View File

@ -792,3 +792,21 @@ def test_pairlist_resolving_with_config_pl_not_exists(mocker, default_conf):
with pytest.raises(OperationalException, match=r"No pairs file found with path.*"):
configuration = Configuration(args)
configuration.get_config()
def test_pairlist_resolving_fallback(mocker):
mocker.patch.object(Path, "exists", MagicMock(return_value=True))
mocker.patch("freqtrade.configuration.configuration.json_load",
MagicMock(return_value=['XRP/BTC', 'ETH/BTC']))
arglist = [
'download-data',
'--exchange', 'binance'
]
args = Arguments(arglist, '').get_parsed_arg()
configuration = Configuration(args)
config = configuration.get_config()
assert config['pairs'] == ['ETH/BTC', 'XRP/BTC']
assert config['exchange']['name'] == 'binance'