From 732523544f2cdc436a15381120e3da4fa596cabf Mon Sep 17 00:00:00 2001 From: creslinux Date: Sun, 3 Jun 2018 22:30:25 +0300 Subject: [PATCH] updated unit test - this file was trying to create a dir in / of the host OS, should never have worked? updated configuration.py call to os to be more pythony! --- freqtrade/configuration.py | 10 +++++----- freqtrade/tests/test_configuration.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/freqtrade/configuration.py b/freqtrade/configuration.py index 181c8ab0b..b114e5b7d 100644 --- a/freqtrade/configuration.py +++ b/freqtrade/configuration.py @@ -4,7 +4,7 @@ This module contains the configuration class import json import logging -import os +from os import path, makedirs from argparse import Namespace from typing import Optional, Dict, Any from jsonschema import Draft4Validator, validate @@ -150,15 +150,15 @@ class Configuration(object): else: exchange = config.get('exchange', {}).get('name').lower() if exchange: - default = os.path.join('freqtrade', 'tests', 'testdata', exchange) + default = path.join('freqtrade', 'tests', 'testdata', exchange) config.update({'datadir': default}) # What if user has no exchange as arg or in file - set catchall else: logger.info("No exchange set") - default = os.path.join('freqtrade', 'tests', 'testdata', 'catchall') + default = path.join('freqtrade', 'tests', 'testdata', 'catchall') - if not os.path.exists(config['datadir']): - os.makedirs(config['datadir']) + if not path.exists(config['datadir']): + makedirs(config['datadir']) logger.info("Made directory: %s", config['datadir']) logger.info('Using data folder: %s ...', config['datadir']) diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index 492fdee70..ca28589e4 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -266,14 +266,14 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non arglist = [ '--config', 'config.json', '--strategy', 'DefaultStrategy', - '--datadir', '/foo/bar', + '--datadir', 'freqtrade/tests/testdata/', 'backtesting', '--ticker-interval', '1m', '--live', '--realistic-simulation', '--refresh-pairs-cached', '--timerange', ':100', - '--export', '/bar/foo' + '--export', 'user_data/data' ] args = Arguments(arglist, '').get_parsed_arg()