Apply isort to tests

This commit is contained in:
Matthias 2020-09-28 19:43:15 +02:00
parent 253b7b763e
commit 9df366d943
31 changed files with 96 additions and 124 deletions

View File

@ -4,10 +4,8 @@ from unittest.mock import MagicMock
import pytest
import rapidjson
from freqtrade.commands.build_config_commands import (ask_user_config,
ask_user_overwrite,
start_new_config,
validate_is_float,
from freqtrade.commands.build_config_commands import (ask_user_config, ask_user_overwrite,
start_new_config, validate_is_float,
validate_is_int)
from freqtrade.exceptions import OperationalException
from tests.conftest import get_args, log_has_re

View File

@ -5,19 +5,16 @@ from unittest.mock import MagicMock, PropertyMock
import arrow
import pytest
from freqtrade.commands import (start_convert_data, start_create_userdir,
start_download_data, start_hyperopt_list,
start_hyperopt_show, start_list_data,
start_list_exchanges, start_list_hyperopts,
start_list_markets, start_list_strategies,
start_list_timeframes, start_new_hyperopt,
start_new_strategy, start_show_trades,
start_test_pairlist, start_trading)
from freqtrade.commands import (start_convert_data, start_create_userdir, start_download_data,
start_hyperopt_list, start_hyperopt_show, start_list_data,
start_list_exchanges, start_list_hyperopts, start_list_markets,
start_list_strategies, start_list_timeframes, start_new_hyperopt,
start_new_strategy, start_show_trades, start_test_pairlist,
start_trading)
from freqtrade.configuration import setup_utils_configuration
from freqtrade.exceptions import OperationalException
from freqtrade.state import RunMode
from tests.conftest import (create_mock_trades, get_args, log_has, log_has_re,
patch_exchange,
from tests.conftest import (create_mock_trades, get_args, log_has, log_has_re, patch_exchange,
patched_configuration_load_config_file)
from tests.conftest_trades import MOCK_TRADE_COUNT

View File

@ -22,8 +22,9 @@ from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.persistence import Trade
from freqtrade.resolvers import ExchangeResolver
from freqtrade.worker import Worker
from tests.conftest_trades import (mock_trade_1, mock_trade_2, mock_trade_3,
mock_trade_4, mock_trade_5, mock_trade_6)
from tests.conftest_trades import (mock_trade_1, mock_trade_2, mock_trade_3, mock_trade_4,
mock_trade_5, mock_trade_6)
logging.getLogger('').setLevel(logging.INFO)

View File

@ -7,16 +7,11 @@ from pandas import DataFrame, DateOffset, Timestamp, to_datetime
from freqtrade.configuration import TimeRange
from freqtrade.constants import LAST_BT_RESULT_FN
from freqtrade.data.btanalysis import (BT_DATA_COLUMNS,
analyze_trade_parallelism,
calculate_market_change,
calculate_max_drawdown,
combine_dataframes_with_mean,
create_cum_profit,
extract_trades_of_period,
get_latest_backtest_filename,
load_backtest_data, load_trades,
load_trades_from_db)
from freqtrade.data.btanalysis import (BT_DATA_COLUMNS, analyze_trade_parallelism,
calculate_market_change, calculate_max_drawdown,
combine_dataframes_with_mean, create_cum_profit,
extract_trades_of_period, get_latest_backtest_filename,
load_backtest_data, load_trades, load_trades_from_db)
from freqtrade.data.history import load_data, load_pair_history
from freqtrade.optimize.backtesting import BacktestResult
from tests.conftest import create_mock_trades

View File

@ -2,13 +2,11 @@
import logging
from freqtrade.configuration.timerange import TimeRange
from freqtrade.data.converter import (convert_ohlcv_format,
convert_trades_format,
ohlcv_fill_up_missing_data,
ohlcv_to_dataframe, trades_dict_to_list,
trades_remove_duplicates, trim_dataframe)
from freqtrade.data.history import (get_timerange, load_data,
load_pair_history, validate_backtest_data)
from freqtrade.data.converter import (convert_ohlcv_format, convert_trades_format,
ohlcv_fill_up_missing_data, ohlcv_to_dataframe,
trades_dict_to_list, trades_remove_duplicates, trim_dataframe)
from freqtrade.data.history import (get_timerange, load_data, load_pair_history,
validate_backtest_data)
from tests.conftest import log_has
from tests.data.test_history import _backup_file, _clean_test_file

View File

@ -15,20 +15,19 @@ from freqtrade.configuration import TimeRange
from freqtrade.constants import AVAILABLE_DATAHANDLERS
from freqtrade.data.converter import ohlcv_to_dataframe
from freqtrade.data.history.hdf5datahandler import HDF5DataHandler
from freqtrade.data.history.history_utils import (
_download_pair_history, _download_trades_history,
_load_cached_data_for_updating, convert_trades_to_ohlcv, get_timerange,
load_data, load_pair_history, refresh_backtest_ohlcv_data,
refresh_backtest_trades_data, refresh_data, validate_backtest_data)
from freqtrade.data.history.idatahandler import (IDataHandler, get_datahandler,
get_datahandlerclass)
from freqtrade.data.history.jsondatahandler import (JsonDataHandler,
JsonGzDataHandler)
from freqtrade.data.history.history_utils import (_download_pair_history, _download_trades_history,
_load_cached_data_for_updating,
convert_trades_to_ohlcv, get_timerange, load_data,
load_pair_history, refresh_backtest_ohlcv_data,
refresh_backtest_trades_data, refresh_data,
validate_backtest_data)
from freqtrade.data.history.idatahandler import IDataHandler, get_datahandler, get_datahandlerclass
from freqtrade.data.history.jsondatahandler import JsonDataHandler, JsonGzDataHandler
from freqtrade.exchange import timeframe_to_minutes
from freqtrade.misc import file_dump_json
from freqtrade.resolvers import StrategyResolver
from tests.conftest import (get_patched_exchange, log_has, log_has_re,
patch_exchange)
from tests.conftest import get_patched_exchange, log_has, log_has_re, patch_exchange
# Change this if modifying UNITTEST/BTC testdatafile
_BTC_UNITTEST_LENGTH = 13681

View File

@ -10,14 +10,15 @@ import numpy as np
import pytest
from pandas import DataFrame, to_datetime
from freqtrade.exceptions import OperationalException
from freqtrade.data.converter import ohlcv_to_dataframe
from freqtrade.edge import Edge, PairInfo
from freqtrade.exceptions import OperationalException
from freqtrade.strategy.interface import SellType
from tests.conftest import get_patched_freqtradebot, log_has
from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe,
_get_frame_time_from_offset)
# Cases to be tested:
# 1) Open trade should be removed from the end
# 2) Two complete trades within dataframe (with sell hit for all)

View File

@ -4,8 +4,7 @@ from unittest.mock import MagicMock
import ccxt
import pytest
from freqtrade.exceptions import (DependencyException, InvalidOrderException,
OperationalException)
from freqtrade.exceptions import DependencyException, InvalidOrderException, OperationalException
from tests.conftest import get_patched_exchange
from tests.exchange.test_exchange import ccxt_exceptionhandlers

View File

@ -9,21 +9,18 @@ import ccxt
import pytest
from pandas import DataFrame
from freqtrade.exceptions import (DDosProtection, DependencyException,
InvalidOrderException, OperationalException,
TemporaryError)
from freqtrade.exceptions import (DDosProtection, DependencyException, InvalidOrderException,
OperationalException, TemporaryError)
from freqtrade.exchange import Binance, Exchange, Kraken
from freqtrade.exchange.common import (API_RETRY_COUNT, API_FETCH_ORDER_RETRY_COUNT,
from freqtrade.exchange.common import (API_FETCH_ORDER_RETRY_COUNT, API_RETRY_COUNT,
calculate_backoff)
from freqtrade.exchange.exchange import (market_is_active,
timeframe_to_minutes,
timeframe_to_msecs,
timeframe_to_next_date,
timeframe_to_prev_date,
from freqtrade.exchange.exchange import (market_is_active, timeframe_to_minutes, timeframe_to_msecs,
timeframe_to_next_date, timeframe_to_prev_date,
timeframe_to_seconds)
from freqtrade.resolvers.exchange_resolver import ExchangeResolver
from tests.conftest import get_patched_exchange, log_has, log_has_re
# Make sure to always keep one exchange here which is NOT subclassed!!
EXCHANGES = ['bittrex', 'binance', 'kraken', 'ftx']

View File

@ -10,6 +10,7 @@ from tests.conftest import get_patched_exchange
from .test_exchange import ccxt_exceptionhandlers
STOPLOSS_ORDERTYPE = 'stop'

View File

@ -8,6 +8,7 @@ from freqtrade.exceptions import DependencyException, InvalidOrderException
from tests.conftest import get_patched_exchange
from tests.exchange.test_exchange import ccxt_exceptionhandlers
STOPLOSS_ORDERTYPE = 'stop-loss'

View File

@ -6,6 +6,7 @@ from pandas import DataFrame
from freqtrade.exchange import timeframe_to_minutes
from freqtrade.strategy.interface import SellType
tests_start_time = arrow.get(2018, 10, 3)
tests_timeframe = '1h'

View File

@ -11,6 +11,7 @@ from tests.conftest import patch_exchange
from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe,
_get_frame_time_from_offset, tests_timeframe)
# Test 0: Sell with signal sell in candle 3
# Test with Stop-loss at 1%
tc0 = BTContainer(data=[

View File

@ -10,8 +10,7 @@ import pytest
from arrow import Arrow
from freqtrade import constants
from freqtrade.commands.optimize_commands import (setup_optimize_configuration,
start_backtesting)
from freqtrade.commands.optimize_commands import setup_optimize_configuration, start_backtesting
from freqtrade.configuration import TimeRange
from freqtrade.data import history
from freqtrade.data.btanalysis import BT_DATA_COLUMNS, evaluate_result_multi
@ -26,6 +25,7 @@ from freqtrade.strategy.interface import SellType
from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,
patched_configuration_load_config_file)
ORDER_TYPES = [
{
'buy': 'limit',

View File

@ -1,9 +1,9 @@
# pragma pylint: disable=missing-docstring,W0212,C0103
import locale
import logging
from copy import deepcopy
from datetime import datetime
from pathlib import Path
from copy import deepcopy
from typing import Dict, List
from unittest.mock import MagicMock, PropertyMock
@ -13,14 +13,12 @@ from arrow import Arrow
from filelock import Timeout
from freqtrade import constants
from freqtrade.commands.optimize_commands import (setup_optimize_configuration,
start_hyperopt)
from freqtrade.commands.optimize_commands import setup_optimize_configuration, start_hyperopt
from freqtrade.data.history import load_data
from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.optimize.default_hyperopt_loss import DefaultHyperOptLoss
from freqtrade.optimize.hyperopt import Hyperopt
from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver,
HyperOptResolver)
from freqtrade.resolvers.hyperopt_resolver import HyperOptLossResolver, HyperOptResolver
from freqtrade.state import RunMode
from freqtrade.strategy.interface import SellType
from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,

View File

@ -5,21 +5,17 @@ from pathlib import Path
import pandas as pd
import pytest
from arrow import Arrow
from freqtrade.configuration import TimeRange
from freqtrade.constants import LAST_BT_RESULT_FN
from freqtrade.data import history
from freqtrade.data.btanalysis import (get_latest_backtest_filename,
load_backtest_data)
from freqtrade.data.btanalysis import get_latest_backtest_filename, load_backtest_data
from freqtrade.edge import PairInfo
from freqtrade.optimize.optimize_reports import (generate_backtest_stats,
generate_daily_stats,
generate_edge_table,
generate_pair_metrics,
from freqtrade.optimize.optimize_reports import (generate_backtest_stats, generate_daily_stats,
generate_edge_table, generate_pair_metrics,
generate_sell_reason_stats,
generate_strategy_metrics,
store_backtest_stats,
text_table_bt_results,
text_table_sell_reason,
generate_strategy_metrics, store_backtest_stats,
text_table_bt_results, text_table_sell_reason,
text_table_strategy)
from freqtrade.resolvers.strategy_resolver import StrategyResolver
from freqtrade.strategy.interface import SellType

View File

@ -13,8 +13,7 @@ from freqtrade.persistence import Trade
from freqtrade.rpc import RPC, RPCException
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
from freqtrade.state import State
from tests.conftest import (create_mock_trades, get_patched_freqtradebot,
patch_get_signal)
from tests.conftest import create_mock_trades, get_patched_freqtradebot, patch_get_signal
# Functions for recurrent object patching

View File

@ -14,8 +14,8 @@ from freqtrade.loggers import setup_logging, setup_logging_pre
from freqtrade.persistence import Trade
from freqtrade.rpc.api_server import BASE_URI, ApiServer
from freqtrade.state import State
from tests.conftest import (create_mock_trades, get_patched_freqtradebot,
log_has, patch_get_signal)
from tests.conftest import create_mock_trades, get_patched_freqtradebot, log_has, patch_get_signal
_TEST_USER = "FreqTrader"
_TEST_PASS = "SuperSecurePassword1!"

View File

@ -1,10 +1,10 @@
# pragma pylint: disable=missing-docstring, C0103
import time
import logging
import time
from unittest.mock import MagicMock
from freqtrade.rpc import RPCMessageType, RPCManager
from tests.conftest import log_has, get_patched_freqtradebot
from freqtrade.rpc import RPCManager, RPCMessageType
from tests.conftest import get_patched_freqtradebot, log_has
def test__init__(mocker, default_conf) -> None:

View File

@ -23,9 +23,8 @@ from freqtrade.rpc import RPCMessageType
from freqtrade.rpc.telegram import Telegram, authorized_only
from freqtrade.state import State
from freqtrade.strategy.interface import SellType
from tests.conftest import (create_mock_trades, get_patched_freqtradebot,
log_has, patch_exchange, patch_get_signal,
patch_whitelist)
from tests.conftest import (create_mock_trades, get_patched_freqtradebot, log_has, patch_exchange,
patch_get_signal, patch_whitelist)
class DummyCls(Telegram):

View File

@ -1,12 +1,13 @@
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame
# --------------------------------
# Add your lib to import here
import talib.abstract as ta
from pandas import DataFrame
from freqtrade.strategy.interface import IStrategy
# --------------------------------
# This class is a sample. Feel free to customize it.
class TestStrategyLegacy(IStrategy):

View File

@ -19,6 +19,7 @@ from tests.conftest import log_has, log_has_re
from .strats.default_strategy import DefaultStrategy
# Avoid to reinit the same object again and again
_STRATEGY = DefaultStrategy(config={})
_STRATEGY.dp = DataProvider({}, None, None)

View File

@ -1,5 +1,5 @@
import pandas as pd
import numpy as np
import pandas as pd
from freqtrade.strategy import merge_informative_pair, timeframe_to_minutes

View File

@ -11,20 +11,18 @@ import pytest
from jsonschema import ValidationError
from freqtrade.commands import Arguments
from freqtrade.configuration import (Configuration, check_exchange,
remove_credentials,
from freqtrade.configuration import (Configuration, check_exchange, remove_credentials,
validate_config_consistency)
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.deprecated_settings import (check_conflicting_settings,
process_deprecated_setting,
process_temporary_deprecated_settings)
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, setup_logging_pre
from freqtrade.state import RunMode
from tests.conftest import (log_has, log_has_re,
patched_configuration_load_config_file)
from tests.conftest import log_has, log_has_re, patched_configuration_load_config_file
@pytest.fixture(scope="function")

View File

@ -4,8 +4,7 @@ from unittest.mock import MagicMock
import pytest
from freqtrade.configuration.directory_operations import (copy_sample_files,
create_datadir,
from freqtrade.configuration.directory_operations import (copy_sample_files, create_datadir,
create_userdata_dir)
from freqtrade.exceptions import OperationalException
from tests.conftest import log_has, log_has_re

View File

@ -10,12 +10,10 @@ from unittest.mock import ANY, MagicMock, PropertyMock
import arrow
import pytest
from freqtrade.constants import (CANCEL_REASON, MATH_CLOSE_PREC,
UNLIMITED_STAKE_AMOUNT)
from freqtrade.exceptions import (DependencyException, ExchangeError,
InsufficientFundsError,
InvalidOrderException, OperationalException,
PricingError, TemporaryError)
from freqtrade.constants import CANCEL_REASON, MATH_CLOSE_PREC, UNLIMITED_STAKE_AMOUNT
from freqtrade.exceptions import (DependencyException, ExchangeError, InsufficientFundsError,
InvalidOrderException, OperationalException, PricingError,
TemporaryError)
from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.persistence import Trade
from freqtrade.persistence.models import Order
@ -23,15 +21,12 @@ from freqtrade.rpc import RPCMessageType
from freqtrade.state import RunMode, State
from freqtrade.strategy.interface import SellCheckTuple, SellType
from freqtrade.worker import Worker
from tests.conftest import (create_mock_trades, get_patched_freqtradebot,
get_patched_worker, log_has, log_has_re,
patch_edge, patch_exchange, patch_get_signal,
from tests.conftest import (create_mock_trades, get_patched_freqtradebot, get_patched_worker,
log_has, log_has_re, patch_edge, patch_exchange, patch_get_signal,
patch_wallet, patch_whitelist)
from tests.conftest_trades import (MOCK_TRADE_COUNT, mock_order_1,
mock_order_2, mock_order_2_sell,
mock_order_3, mock_order_3_sell,
mock_order_4, mock_order_5_stoploss,
mock_order_6_sell)
from tests.conftest_trades import (MOCK_TRADE_COUNT, mock_order_1, mock_order_2, mock_order_2_sell,
mock_order_3, mock_order_3_sell, mock_order_4,
mock_order_5_stoploss, mock_order_6_sell)
def patch_RPCManager(mocker) -> MagicMock:

View File

@ -1,7 +1,8 @@
import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy as np
import pandas as pd
import freqtrade.vendor.qtpylib.indicators as qtpylib
def test_crossed_numpy_types():
"""

View File

@ -1,11 +1,11 @@
# pragma pylint: disable=missing-docstring
from copy import deepcopy
from pathlib import Path
from unittest.mock import MagicMock, PropertyMock
import pytest
from pathlib import Path
from freqtrade.commands import Arguments
from freqtrade.exceptions import FreqtradeException, OperationalException
from freqtrade.freqtradebot import FreqtradeBot

View File

@ -7,9 +7,8 @@ from unittest.mock import MagicMock
import pytest
from freqtrade.data.converter import ohlcv_to_dataframe
from freqtrade.misc import (datesarray_to_datetimearray, file_dump_json,
file_load_json, format_ms_time, pair_to_filename,
plural, render_template,
from freqtrade.misc import (datesarray_to_datetimearray, file_dump_json, file_load_json,
format_ms_time, pair_to_filename, plural, render_template,
render_template_with_fallback, safe_value_fallback,
safe_value_fallback2, shorten_date)

View File

@ -13,13 +13,10 @@ from freqtrade.configuration import TimeRange
from freqtrade.data import history
from freqtrade.data.btanalysis import create_cum_profit, load_backtest_data
from freqtrade.exceptions import OperationalException
from freqtrade.plot.plotting import (add_indicators, add_profit,
create_plotconfig,
generate_candlestick_graph,
generate_plot_filename,
generate_profit_graph, init_plotscript,
load_and_plot_trades, plot_profit,
plot_trades, store_plot_file)
from freqtrade.plot.plotting import (add_indicators, add_profit, create_plotconfig,
generate_candlestick_graph, generate_plot_filename,
generate_profit_graph, init_plotscript, load_and_plot_trades,
plot_profit, plot_trades, store_plot_file)
from freqtrade.resolvers import StrategyResolver
from tests.conftest import get_args, log_has, log_has_re, patch_exchange

View File

@ -1,5 +1,5 @@
import talib.abstract as ta
import pandas as pd
import talib.abstract as ta
def test_talib_bollingerbands_near_zero_values():