Merge pull request #2236 from freqtrade/move_tests
Move tests to top level
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| [run] | ||||
| omit = | ||||
|     scripts/* | ||||
|     freqtrade/tests/* | ||||
|     freqtrade/vendor/* | ||||
|     freqtrade/__main__.py | ||||
|     tests/* | ||||
|   | ||||
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,11 +1,7 @@ | ||||
| # Freqtrade rules | ||||
| freqtrade/tests/testdata/*.json | ||||
| hyperopt_conf.py | ||||
| config*.json | ||||
| *.sqlite | ||||
| .hyperopt | ||||
| logfile.txt | ||||
| hyperopt_trials.pickle | ||||
| user_data/* | ||||
| !user_data/notebooks | ||||
| user_data/notebooks/* | ||||
|   | ||||
| @@ -22,19 +22,19 @@ jobs: | ||||
|   include: | ||||
|     - stage: tests | ||||
|       script: | ||||
|       - pytest --random-order --cov=freqtrade --cov-config=.coveragerc freqtrade/tests/ | ||||
|       - pytest --random-order --cov=freqtrade --cov-config=.coveragerc | ||||
|       # Allow failure for coveralls | ||||
|       - coveralls || true | ||||
|       name: pytest | ||||
|     - script: | ||||
|       - cp config.json.example config.json | ||||
|       - freqtrade --datadir freqtrade/tests/testdata backtesting | ||||
|       - freqtrade --datadir tests/testdata backtesting | ||||
|       name: backtest | ||||
|     - script: | ||||
|       - cp config.json.example config.json | ||||
|       - freqtrade --datadir freqtrade/tests/testdata hyperopt -e 5 | ||||
|       - freqtrade --datadir tests/testdata hyperopt -e 5 | ||||
|       name: hyperopt | ||||
|     - script: flake8 freqtrade scripts | ||||
|     - script: flake8 | ||||
|       name: flake8 | ||||
|     - script: | ||||
|       # Test Documentation boxes - | ||||
|   | ||||
| @@ -28,19 +28,19 @@ make it pass. It means you have introduced a regression. | ||||
| #### Test the whole project | ||||
|  | ||||
| ```bash | ||||
| pytest freqtrade | ||||
| pytest | ||||
| ``` | ||||
|  | ||||
| #### Test only one file | ||||
|  | ||||
| ```bash | ||||
| pytest freqtrade/tests/test_<file_name>.py | ||||
| pytest tests/test_<file_name>.py | ||||
| ``` | ||||
|  | ||||
| #### Test only one method from one file | ||||
|  | ||||
| ```bash | ||||
| pytest freqtrade/tests/test_<file_name>.py::test_<method_name> | ||||
| pytest tests/test_<file_name>.py::test_<method_name> | ||||
| ``` | ||||
|  | ||||
| ### 2. Test if your code is PEP8 compliant | ||||
|   | ||||
| @@ -2,4 +2,3 @@ include LICENSE | ||||
| include README.md | ||||
| include config.json.example | ||||
| recursive-include freqtrade *.py | ||||
| include freqtrade/tests/testdata/*.json | ||||
|   | ||||
| @@ -43,12 +43,11 @@ Now you have good Buy and Sell strategies and some historic data, you want to te | ||||
| real data. This is what we call | ||||
| [backtesting](https://en.wikipedia.org/wiki/Backtesting). | ||||
|  | ||||
| Backtesting will use the crypto-currencies (pair) from your config file | ||||
| and load static tickers located in | ||||
| [/freqtrade/tests/testdata](https://github.com/freqtrade/freqtrade/tree/develop/freqtrade/tests/testdata). | ||||
| If the 5 min and 1 min ticker for the crypto-currencies to test is not | ||||
| already in the `testdata` directory, backtesting will download them | ||||
| automatically. Testdata files will not be updated until you specify it. | ||||
| Backtesting will use the crypto-currencies (pairs) from your config file | ||||
| and load ticker data from `user_data/data/<exchange>` by default. | ||||
| If no data is available for the exchange / pair / ticker interval combination, backtesting will | ||||
| ask you to download them first using `freqtrade download-data`.  | ||||
| For details on downloading, please refer to the [relevant section](#Getting-data-for-backtesting-and-hyperopt) in the documentation. | ||||
|  | ||||
| The result of backtesting will confirm you if your bot has better odds of making a profit than a loss. | ||||
|  | ||||
|   | ||||
| @@ -30,7 +30,7 @@ These are available from `conftest.py` and can be imported in any test module. | ||||
| A sample check looks as follows: | ||||
|  | ||||
| ``` python | ||||
| from freqtrade.tests.conftest import log_has, log_has_re | ||||
| from tests.conftest import log_has, log_has_re | ||||
|  | ||||
| def test_method_to_test(caplog): | ||||
|     method_to_test() | ||||
|   | ||||
| @@ -179,5 +179,5 @@ freqtrade plot-profit  -p LTC/BTC --db-url sqlite:///tradesv3.sqlite --trade-sou | ||||
| ``` | ||||
|  | ||||
| ``` bash | ||||
| freqtrade plot-profit --datadir ../freqtrade/freqtrade/tests/testdata-20171221/ -p LTC/BTC | ||||
| freqtrade plot-profit --datadir user_data/data/binance_save/ -p LTC/BTC | ||||
| ``` | ||||
|   | ||||
| @@ -2,9 +2,14 @@ | ||||
| #ignore = | ||||
| max-line-length = 100 | ||||
| max-complexity = 12 | ||||
| exclude = | ||||
|     .git, | ||||
|     __pycache__, | ||||
|     .eggs, | ||||
|     user_data, | ||||
|  | ||||
| [mypy] | ||||
| ignore_missing_imports = True | ||||
|  | ||||
| [mypy-freqtrade.tests.*] | ||||
| [mypy-tests.*] | ||||
| ignore_errors = True | ||||
|   | ||||
| @@ -891,8 +891,8 @@ def tickers(): | ||||
| 
 | ||||
| 
 | ||||
| @pytest.fixture | ||||
| def result(): | ||||
|     with Path('freqtrade/tests/testdata/UNITTEST_BTC-1m.json').open('r') as data_file: | ||||
| def result(testdatadir): | ||||
|     with (testdatadir / 'UNITTEST_BTC-1m.json').open('r') as data_file: | ||||
|         return parse_ticker_dataframe(json.load(data_file), '1m', pair="UNITTEST/BTC", | ||||
|                                       fill_missing=True) | ||||
| 
 | ||||
| @@ -12,7 +12,7 @@ from freqtrade.data.btanalysis import (BT_DATA_COLUMNS, | ||||
|                                        load_backtest_data, load_trades, | ||||
|                                        load_trades_from_db) | ||||
| from freqtrade.data.history import load_data, load_pair_history | ||||
| from freqtrade.tests.test_persistence import create_mock_trades | ||||
| from tests.test_persistence import create_mock_trades | ||||
| 
 | ||||
| 
 | ||||
| def test_load_backtest_data(testdatadir): | ||||
| @@ -3,7 +3,7 @@ import logging | ||||
| 
 | ||||
| from freqtrade.data.converter import parse_ticker_dataframe, ohlcv_fill_up_missing_data | ||||
| from freqtrade.data.history import load_pair_history, validate_backtest_data, get_timeframe | ||||
| from freqtrade.tests.conftest import log_has | ||||
| from tests.conftest import log_has | ||||
| 
 | ||||
| 
 | ||||
| def test_dataframe_correct_columns(result): | ||||
| @@ -4,7 +4,7 @@ from pandas import DataFrame | ||||
| 
 | ||||
| from freqtrade.data.dataprovider import DataProvider | ||||
| from freqtrade.state import RunMode | ||||
| from freqtrade.tests.conftest import get_patched_exchange | ||||
| from tests.conftest import get_patched_exchange | ||||
| 
 | ||||
| 
 | ||||
| def test_ohlcv(mocker, default_conf, ticker_history): | ||||
| @@ -22,7 +22,7 @@ from freqtrade.data.history import (download_pair_history, | ||||
| from freqtrade.exchange import timeframe_to_minutes | ||||
| from freqtrade.misc import file_dump_json | ||||
| from freqtrade.strategy.default_strategy import DefaultStrategy | ||||
| from freqtrade.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 | ||||
| @@ -160,7 +160,7 @@ def test_load_data_live_noexchange(default_conf, mocker, caplog, testdatadir) -> | ||||
| 
 | ||||
| 
 | ||||
| def test_testdata_path(testdatadir) -> None: | ||||
|     assert str(Path('freqtrade') / 'tests' / 'testdata') in str(testdatadir) | ||||
|     assert str(Path('tests') / 'testdata') in str(testdatadir) | ||||
| 
 | ||||
| 
 | ||||
| def test_load_cached_data_for_updating(mocker) -> None: | ||||
| @@ -14,10 +14,9 @@ from freqtrade import OperationalException | ||||
| from freqtrade.data.converter import parse_ticker_dataframe | ||||
| from freqtrade.edge import Edge, PairInfo | ||||
| from freqtrade.strategy.interface import SellType | ||||
| from freqtrade.tests.conftest import get_patched_freqtradebot, log_has | ||||
| from freqtrade.tests.optimize import (BTContainer, BTrade, | ||||
|                                       _build_backtest_dataframe, | ||||
|                                       _get_frame_time_from_offset) | ||||
| 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 | ||||
| @@ -6,7 +6,7 @@ import pytest | ||||
| 
 | ||||
| from freqtrade import (DependencyException, InvalidOrderException, | ||||
|                        OperationalException, TemporaryError) | ||||
| from freqtrade.tests.conftest import get_patched_exchange | ||||
| from tests.conftest import get_patched_exchange | ||||
| 
 | ||||
| 
 | ||||
| def test_stoploss_limit_order(default_conf, mocker): | ||||
| @@ -20,7 +20,7 @@ from freqtrade.exchange.exchange import (API_RETRY_COUNT, timeframe_to_minutes, | ||||
|                                          timeframe_to_prev_date, | ||||
|                                          timeframe_to_seconds) | ||||
| from freqtrade.resolvers.exchange_resolver import ExchangeResolver | ||||
| from freqtrade.tests.conftest import get_patched_exchange, log_has, log_has_re | ||||
| 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', ] | ||||
| @@ -3,7 +3,7 @@ | ||||
| from random import randint | ||||
| from unittest.mock import MagicMock | ||||
| 
 | ||||
| from freqtrade.tests.conftest import get_patched_exchange | ||||
| from tests.conftest import get_patched_exchange | ||||
| 
 | ||||
| 
 | ||||
| def test_buy_kraken_trading_agreement(default_conf, mocker): | ||||
| @@ -8,11 +8,9 @@ from pandas import DataFrame | ||||
| from freqtrade.data.history import get_timeframe | ||||
| from freqtrade.optimize.backtesting import Backtesting | ||||
| from freqtrade.strategy.interface import SellType | ||||
| from freqtrade.tests.conftest import patch_exchange | ||||
| from freqtrade.tests.optimize import (BTContainer, BTrade, | ||||
|                                       _build_backtest_dataframe, | ||||
|                                       _get_frame_time_from_offset, | ||||
|                                       tests_ticker_interval) | ||||
| from tests.conftest import patch_exchange | ||||
| from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe, | ||||
|                             _get_frame_time_from_offset, tests_ticker_interval) | ||||
| 
 | ||||
| # Test 0: Sell with signal sell in candle 3 | ||||
| # Test with Stop-loss at 1% | ||||
| @@ -22,9 +22,8 @@ from freqtrade.optimize.backtesting import Backtesting | ||||
| from freqtrade.state import RunMode | ||||
| from freqtrade.strategy.default_strategy import DefaultStrategy | ||||
| from freqtrade.strategy.interface import SellType | ||||
| from freqtrade.tests.conftest import (get_args, log_has, log_has_re, | ||||
|                                       patch_exchange, | ||||
|                                       patched_configuration_load_config_file) | ||||
| from tests.conftest import (get_args, log_has, log_has_re, patch_exchange, | ||||
|                             patched_configuration_load_config_file) | ||||
| 
 | ||||
| 
 | ||||
| def trim_dictlist(dict_list, num): | ||||
| @@ -807,7 +806,7 @@ def test_backtest_record(default_conf, fee, mocker): | ||||
|         assert dur > 0 | ||||
| 
 | ||||
| 
 | ||||
| def test_backtest_start_timerange(default_conf, mocker, caplog): | ||||
| def test_backtest_start_timerange(default_conf, mocker, caplog, testdatadir): | ||||
|     default_conf['exchange']['pair_whitelist'] = ['UNITTEST/BTC'] | ||||
| 
 | ||||
|     async def load_pairs(pair, timeframe, since): | ||||
| @@ -824,7 +823,7 @@ def test_backtest_start_timerange(default_conf, mocker, caplog): | ||||
|     args = [ | ||||
|         '--config', 'config.json', | ||||
|         '--strategy', 'DefaultStrategy', | ||||
|         '--datadir', 'freqtrade/tests/testdata', | ||||
|         '--datadir', str(testdatadir), | ||||
|         'backtesting', | ||||
|         '--ticker-interval', '1m', | ||||
|         '--timerange', '-100', | ||||
| @@ -838,7 +837,7 @@ def test_backtest_start_timerange(default_conf, mocker, caplog): | ||||
|         'Parameter -i/--ticker-interval detected ... Using ticker_interval: 1m ...', | ||||
|         'Ignoring max_open_trades (--disable-max-market-positions was used) ...', | ||||
|         'Parameter --timerange detected: -100 ...', | ||||
|         'Using data directory: freqtrade/tests/testdata ...', | ||||
|         f'Using data directory: {testdatadir} ...', | ||||
|         'Using stake_currency: BTC ...', | ||||
|         'Using stake_amount: 0.001 ...', | ||||
|         'Backtesting with data from 2017-11-14T21:17:00+00:00 ' | ||||
| @@ -850,7 +849,7 @@ def test_backtest_start_timerange(default_conf, mocker, caplog): | ||||
|         assert log_has(line, caplog) | ||||
| 
 | ||||
| 
 | ||||
| def test_backtest_start_multi_strat(default_conf, mocker, caplog): | ||||
| def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir): | ||||
|     default_conf['exchange']['pair_whitelist'] = ['UNITTEST/BTC'] | ||||
| 
 | ||||
|     async def load_pairs(pair, timeframe, since): | ||||
| @@ -870,7 +869,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog): | ||||
| 
 | ||||
|     args = [ | ||||
|         '--config', 'config.json', | ||||
|         '--datadir', 'freqtrade/tests/testdata', | ||||
|         '--datadir', str(testdatadir), | ||||
|         'backtesting', | ||||
|         '--ticker-interval', '1m', | ||||
|         '--timerange', '-100', | ||||
| @@ -892,7 +891,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog): | ||||
|         'Parameter -i/--ticker-interval detected ... Using ticker_interval: 1m ...', | ||||
|         'Ignoring max_open_trades (--disable-max-market-positions was used) ...', | ||||
|         'Parameter --timerange detected: -100 ...', | ||||
|         'Using data directory: freqtrade/tests/testdata ...', | ||||
|         f'Using data directory: {testdatadir} ...', | ||||
|         'Using stake_currency: BTC ...', | ||||
|         'Using stake_amount: 0.001 ...', | ||||
|         'Backtesting with data from 2017-11-14T21:17:00+00:00 ' | ||||
| @@ -9,9 +9,8 @@ from freqtrade.edge import PairInfo | ||||
| from freqtrade.optimize import setup_configuration, start_edge | ||||
| from freqtrade.optimize.edge_cli import EdgeCli | ||||
| from freqtrade.state import RunMode | ||||
| from freqtrade.tests.conftest import (get_args, log_has, log_has_re, | ||||
|                                       patch_exchange, | ||||
|                                       patched_configuration_load_config_file) | ||||
| from tests.conftest import (get_args, log_has, log_has_re, patch_exchange, | ||||
|                             patched_configuration_load_config_file) | ||||
| 
 | ||||
| 
 | ||||
| def test_setup_configuration_without_arguments(mocker, default_conf, caplog) -> None: | ||||
| @@ -1,13 +1,12 @@ | ||||
| # pragma pylint: disable=missing-docstring,W0212,C0103 | ||||
| import os | ||||
| from datetime import datetime | ||||
| from pathlib import Path | ||||
| from unittest.mock import MagicMock, PropertyMock | ||||
| 
 | ||||
| import pandas as pd | ||||
| import pytest | ||||
| from arrow import Arrow | ||||
| from filelock import Timeout | ||||
| from pathlib import Path | ||||
| 
 | ||||
| from freqtrade import OperationalException | ||||
| from freqtrade.data.converter import parse_ticker_dataframe | ||||
| @@ -16,12 +15,12 @@ from freqtrade.optimize import setup_configuration, start_hyperopt | ||||
| from freqtrade.optimize.default_hyperopt import DefaultHyperOpts | ||||
| from freqtrade.optimize.default_hyperopt_loss import DefaultHyperOptLoss | ||||
| from freqtrade.optimize.hyperopt import Hyperopt | ||||
| from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver, HyperOptLossResolver | ||||
| from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver, | ||||
|                                                    HyperOptResolver) | ||||
| from freqtrade.state import RunMode | ||||
| from freqtrade.strategy.interface import SellType | ||||
| from freqtrade.tests.conftest import (get_args, log_has, log_has_re, | ||||
|                                       patch_exchange, | ||||
|                                       patched_configuration_load_config_file) | ||||
| from tests.conftest import (get_args, log_has, log_has_re, patch_exchange, | ||||
|                             patched_configuration_load_config_file) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.fixture(scope='function') | ||||
| @@ -47,14 +46,14 @@ def hyperopt_results(): | ||||
| 
 | ||||
| 
 | ||||
| # Functions for recurrent object patching | ||||
| def create_trials(mocker, hyperopt) -> None: | ||||
| def create_trials(mocker, hyperopt, testdatadir) -> None: | ||||
|     """ | ||||
|     When creating trials, mock the hyperopt Trials so that *by default* | ||||
|       - we don't create any pickle'd files in the filesystem | ||||
|       - we might have a pickle'd file so make sure that we return | ||||
|         false when looking for it | ||||
|     """ | ||||
|     hyperopt.trials_file = Path('freqtrade/tests/optimize/ut_trials.pickle') | ||||
|     hyperopt.trials_file = testdatadir / 'optimize/ut_trials.pickle' | ||||
| 
 | ||||
|     mocker.patch.object(Path, "is_file", MagicMock(return_value=False)) | ||||
|     stat_mock = MagicMock() | ||||
| @@ -356,23 +355,23 @@ def test_no_log_if_loss_does_not_improve(hyperopt, caplog) -> None: | ||||
|     assert caplog.record_tuples == [] | ||||
| 
 | ||||
| 
 | ||||
| def test_save_trials_saves_trials(mocker, hyperopt, caplog) -> None: | ||||
|     trials = create_trials(mocker, hyperopt) | ||||
| def test_save_trials_saves_trials(mocker, hyperopt, testdatadir, caplog) -> None: | ||||
|     trials = create_trials(mocker, hyperopt, testdatadir) | ||||
|     mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None) | ||||
|     hyperopt.trials = trials | ||||
|     hyperopt.save_trials() | ||||
| 
 | ||||
|     trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle') | ||||
|     assert log_has("Saving 1 evaluations to '{}'".format(trials_file), caplog) | ||||
|     trials_file = testdatadir / 'optimize' / 'ut_trials.pickle' | ||||
|     assert log_has(f"Saving 1 evaluations to '{trials_file}'", caplog) | ||||
|     mock_dump.assert_called_once() | ||||
| 
 | ||||
| 
 | ||||
| def test_read_trials_returns_trials_file(mocker, hyperopt, caplog) -> None: | ||||
|     trials = create_trials(mocker, hyperopt) | ||||
| def test_read_trials_returns_trials_file(mocker, hyperopt, testdatadir, caplog) -> None: | ||||
|     trials = create_trials(mocker, hyperopt, testdatadir) | ||||
|     mock_load = mocker.patch('freqtrade.optimize.hyperopt.load', return_value=trials) | ||||
|     hyperopt_trial = hyperopt.read_trials() | ||||
|     trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle') | ||||
|     assert log_has("Reading Trials from '{}'".format(trials_file), caplog) | ||||
|     trials_file = testdatadir / 'optimize' / 'ut_trials.pickle' | ||||
|     assert log_has(f"Reading Trials from '{trials_file}'", caplog) | ||||
|     assert hyperopt_trial == trials | ||||
|     mock_load.assert_called_once() | ||||
| 
 | ||||
| @@ -5,7 +5,7 @@ from unittest.mock import MagicMock, PropertyMock | ||||
| from freqtrade import OperationalException | ||||
| from freqtrade.constants import AVAILABLE_PAIRLISTS | ||||
| from freqtrade.resolvers import PairListResolver | ||||
| from freqtrade.tests.conftest import get_patched_freqtradebot | ||||
| from tests.conftest import get_patched_freqtradebot | ||||
| import pytest | ||||
| 
 | ||||
| # whitelist, blacklist | ||||
| @@ -8,7 +8,7 @@ import pytest | ||||
| from requests.exceptions import RequestException | ||||
| 
 | ||||
| from freqtrade.rpc.fiat_convert import CryptoFiat, CryptoToFiatConverter | ||||
| from freqtrade.tests.conftest import log_has | ||||
| from tests.conftest import log_has | ||||
| 
 | ||||
| 
 | ||||
| def test_pair_convertion_object(): | ||||
| @@ -14,7 +14,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 freqtrade.tests.conftest import patch_exchange, patch_get_signal | ||||
| from tests.conftest import patch_exchange, patch_get_signal | ||||
| 
 | ||||
| 
 | ||||
| # Functions for recurrent object patching | ||||
| @@ -13,9 +13,7 @@ from freqtrade.__init__ import __version__ | ||||
| from freqtrade.persistence import Trade | ||||
| from freqtrade.rpc.api_server import BASE_URI, ApiServer | ||||
| from freqtrade.state import State | ||||
| from freqtrade.tests.conftest import (get_patched_freqtradebot, log_has, | ||||
|                                       patch_get_signal) | ||||
| 
 | ||||
| from tests.conftest import get_patched_freqtradebot, log_has, patch_get_signal | ||||
| 
 | ||||
| _TEST_USER = "FreqTrader" | ||||
| _TEST_PASS = "SuperSecurePassword1!" | ||||
| @@ -4,7 +4,7 @@ import logging | ||||
| from unittest.mock import MagicMock | ||||
| 
 | ||||
| from freqtrade.rpc import RPCMessageType, RPCManager | ||||
| from freqtrade.tests.conftest import log_has, get_patched_freqtradebot | ||||
| from tests.conftest import log_has, get_patched_freqtradebot | ||||
| 
 | ||||
| 
 | ||||
| def test__init__(mocker, default_conf) -> None: | ||||
| @@ -21,8 +21,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 freqtrade.tests.conftest import (get_patched_freqtradebot, log_has, | ||||
|                                       patch_exchange, patch_get_signal) | ||||
| from tests.conftest import (get_patched_freqtradebot, log_has, patch_exchange, | ||||
|                             patch_get_signal) | ||||
| 
 | ||||
| 
 | ||||
| class DummyCls(Telegram): | ||||
| @@ -8,7 +8,7 @@ from requests import RequestException | ||||
| from freqtrade.rpc import RPCMessageType | ||||
| from freqtrade.rpc.webhook import Webhook | ||||
| from freqtrade.strategy.interface import SellType | ||||
| from freqtrade.tests.conftest import get_patched_freqtradebot, log_has | ||||
| from tests.conftest import get_patched_freqtradebot, log_has | ||||
| 
 | ||||
| 
 | ||||
| def get_webhook_dict() -> dict: | ||||
| @@ -1,19 +1,8 @@ | ||||
| import json | ||||
| 
 | ||||
| import pytest | ||||
| from pandas import DataFrame | ||||
| 
 | ||||
| from freqtrade.data.converter import parse_ticker_dataframe | ||||
| from freqtrade.strategy.default_strategy import DefaultStrategy | ||||
| 
 | ||||
| 
 | ||||
| @pytest.fixture | ||||
| def result(): | ||||
|     with open('freqtrade/tests/testdata/ETH_BTC-1m.json') as data_file: | ||||
|         return parse_ticker_dataframe(json.load(data_file), '1m', pair="UNITTEST/BTC", | ||||
|                                       fill_missing=True) | ||||
| 
 | ||||
| 
 | ||||
| def test_default_strategy_structure(): | ||||
|     assert hasattr(DefaultStrategy, 'minimal_roi') | ||||
|     assert hasattr(DefaultStrategy, 'stoploss') | ||||
| @@ -10,7 +10,7 @@ from freqtrade.configuration import TimeRange | ||||
| from freqtrade.data.converter import parse_ticker_dataframe | ||||
| from freqtrade.data.history import load_tickerdata_file | ||||
| from freqtrade.persistence import Trade | ||||
| from freqtrade.tests.conftest import get_patched_exchange, log_has | ||||
| from tests.conftest import get_patched_exchange, log_has | ||||
| from freqtrade.strategy.default_strategy import DefaultStrategy | ||||
| 
 | ||||
| # Avoid to reinit the same object again and again | ||||
| @@ -12,12 +12,12 @@ from pandas import DataFrame | ||||
| from freqtrade import OperationalException | ||||
| from freqtrade.resolvers import StrategyResolver | ||||
| from freqtrade.strategy.interface import IStrategy | ||||
| from freqtrade.tests.conftest import log_has, log_has_re | ||||
| from tests.conftest import log_has, log_has_re | ||||
| 
 | ||||
| 
 | ||||
| def test_search_strategy(): | ||||
|     default_config = {} | ||||
|     default_location = Path(__file__).parent.parent.parent.joinpath('strategy').resolve() | ||||
|     default_location = Path(__file__).parent.parent.joinpath('strategy').resolve() | ||||
| 
 | ||||
|     s, _ = StrategyResolver._search_object( | ||||
|         directory=default_location, | ||||
| @@ -10,7 +10,8 @@ import pytest | ||||
| from jsonschema import Draft4Validator, ValidationError, validate | ||||
| 
 | ||||
| from freqtrade import OperationalException, constants | ||||
| from freqtrade.configuration import Arguments, Configuration, validate_config_consistency | ||||
| from freqtrade.configuration import (Arguments, Configuration, | ||||
|                                      validate_config_consistency) | ||||
| from freqtrade.configuration.check_exchange import check_exchange | ||||
| from freqtrade.configuration.config_validation import validate_config_schema | ||||
| from freqtrade.configuration.directory_operations import (create_datadir, | ||||
| @@ -19,13 +20,13 @@ from freqtrade.configuration.load_config import load_config_file | ||||
| from freqtrade.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL | ||||
| from freqtrade.loggers import _set_loggers | ||||
| from freqtrade.state import RunMode | ||||
| from freqtrade.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") | ||||
| def all_conf(): | ||||
|     config_file = Path(__file__).parents[2] / "config_full.json.example" | ||||
|     config_file = Path(__file__).parents[1] / "config_full.json.example" | ||||
|     print(config_file) | ||||
|     conf = load_config_file(str(config_file)) | ||||
|     return conf | ||||
| @@ -16,13 +16,12 @@ from freqtrade.data.dataprovider import DataProvider | ||||
| from freqtrade.freqtradebot import FreqtradeBot | ||||
| from freqtrade.persistence import Trade | ||||
| from freqtrade.rpc import RPCMessageType | ||||
| from freqtrade.state import State, RunMode | ||||
| from freqtrade.state import RunMode, State | ||||
| from freqtrade.strategy.interface import SellCheckTuple, SellType | ||||
| from freqtrade.tests.conftest import (get_patched_freqtradebot, | ||||
|                                       get_patched_worker, log_has, log_has_re, | ||||
|                                       patch_edge, patch_exchange, | ||||
|                                       patch_get_signal, patch_wallet) | ||||
| from freqtrade.worker import Worker | ||||
| from tests.conftest import (get_patched_freqtradebot, get_patched_worker, | ||||
|                             log_has, log_has_re, patch_edge, patch_exchange, | ||||
|                             patch_get_signal, patch_wallet) | ||||
| 
 | ||||
| 
 | ||||
| def patch_RPCManager(mocker) -> MagicMock: | ||||
| @@ -10,9 +10,9 @@ from freqtrade.configuration import Arguments | ||||
| from freqtrade.freqtradebot import FreqtradeBot | ||||
| from freqtrade.main import main | ||||
| from freqtrade.state import State | ||||
| from freqtrade.tests.conftest import (log_has, patch_exchange, | ||||
|                                       patched_configuration_load_config_file) | ||||
| from freqtrade.worker import Worker | ||||
| from tests.conftest import (log_has, patch_exchange, | ||||
|                             patched_configuration_load_config_file) | ||||
| 
 | ||||
| 
 | ||||
| def test_parse_args_backtesting(mocker) -> None: | ||||
| @@ -8,7 +8,7 @@ from sqlalchemy import create_engine | ||||
| 
 | ||||
| from freqtrade import OperationalException, constants | ||||
| from freqtrade.persistence import Trade, clean_dry_run_db, init | ||||
| from freqtrade.tests.conftest import log_has | ||||
| from tests.conftest import log_has | ||||
| 
 | ||||
| 
 | ||||
| def create_mock_trades(fee): | ||||
| @@ -19,7 +19,7 @@ from freqtrade.plot.plotting import (add_indicators, add_profit, | ||||
|                                      generate_profit_graph, init_plotscript, | ||||
|                                      plot_profit, plot_trades, store_plot_file) | ||||
| from freqtrade.strategy.default_strategy import DefaultStrategy | ||||
| from freqtrade.tests.conftest import get_args, log_has, log_has_re | ||||
| from tests.conftest import get_args, log_has, log_has_re | ||||
| 
 | ||||
| 
 | ||||
| def fig_generating_mock(fig, *args, **kwargs): | ||||
| @@ -4,7 +4,7 @@ from unittest.mock import MagicMock, PropertyMock | ||||
| import pytest | ||||
| 
 | ||||
| from freqtrade.state import RunMode | ||||
| from freqtrade.tests.conftest import get_args, log_has, patch_exchange | ||||
| from tests.conftest import get_args, log_has, patch_exchange | ||||
| from freqtrade.utils import (setup_utils_configuration, start_create_userdir, | ||||
|                              start_download_data, start_list_exchanges) | ||||
| 
 | ||||
| @@ -1,5 +1,5 @@ | ||||
| # pragma pylint: disable=missing-docstring | ||||
| from freqtrade.tests.conftest import get_patched_freqtradebot | ||||
| from tests.conftest import get_patched_freqtradebot | ||||
| from unittest.mock import MagicMock | ||||
| 
 | ||||
| 
 | ||||
		Reference in New Issue
	
	Block a user