Merge pull request #2236 from freqtrade/move_tests

Move tests to top level
This commit is contained in:
Matthias 2019-09-08 19:18:44 +02:00 committed by GitHub
commit 242ac4d8f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
81 changed files with 88 additions and 108 deletions

View File

@ -1,6 +1,6 @@
[run] [run]
omit = omit =
scripts/* scripts/*
freqtrade/tests/*
freqtrade/vendor/* freqtrade/vendor/*
freqtrade/__main__.py freqtrade/__main__.py
tests/*

4
.gitignore vendored
View File

@ -1,11 +1,7 @@
# Freqtrade rules # Freqtrade rules
freqtrade/tests/testdata/*.json
hyperopt_conf.py
config*.json config*.json
*.sqlite *.sqlite
.hyperopt
logfile.txt logfile.txt
hyperopt_trials.pickle
user_data/* user_data/*
!user_data/notebooks !user_data/notebooks
user_data/notebooks/* user_data/notebooks/*

View File

@ -22,19 +22,19 @@ jobs:
include: include:
- stage: tests - stage: tests
script: script:
- pytest --random-order --cov=freqtrade --cov-config=.coveragerc freqtrade/tests/ - pytest --random-order --cov=freqtrade --cov-config=.coveragerc
# Allow failure for coveralls # Allow failure for coveralls
- coveralls || true - coveralls || true
name: pytest name: pytest
- script: - script:
- cp config.json.example config.json - cp config.json.example config.json
- freqtrade --datadir freqtrade/tests/testdata backtesting - freqtrade --datadir tests/testdata backtesting
name: backtest name: backtest
- script: - script:
- cp config.json.example config.json - cp config.json.example config.json
- freqtrade --datadir freqtrade/tests/testdata hyperopt -e 5 - freqtrade --datadir tests/testdata hyperopt -e 5
name: hyperopt name: hyperopt
- script: flake8 freqtrade scripts - script: flake8
name: flake8 name: flake8
- script: - script:
# Test Documentation boxes - # Test Documentation boxes -

View File

@ -28,19 +28,19 @@ make it pass. It means you have introduced a regression.
#### Test the whole project #### Test the whole project
```bash ```bash
pytest freqtrade pytest
``` ```
#### Test only one file #### Test only one file
```bash ```bash
pytest freqtrade/tests/test_<file_name>.py pytest tests/test_<file_name>.py
``` ```
#### Test only one method from one file #### Test only one method from one file
```bash ```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. Test if your code is PEP8 compliant

View File

@ -2,4 +2,3 @@ include LICENSE
include README.md include README.md
include config.json.example include config.json.example
recursive-include freqtrade *.py recursive-include freqtrade *.py
include freqtrade/tests/testdata/*.json

View File

@ -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 real data. This is what we call
[backtesting](https://en.wikipedia.org/wiki/Backtesting). [backtesting](https://en.wikipedia.org/wiki/Backtesting).
Backtesting will use the crypto-currencies (pair) from your config file Backtesting will use the crypto-currencies (pairs) from your config file
and load static tickers located in and load ticker data from `user_data/data/<exchange>` by default.
[/freqtrade/tests/testdata](https://github.com/freqtrade/freqtrade/tree/develop/freqtrade/tests/testdata). If no data is available for the exchange / pair / ticker interval combination, backtesting will
If the 5 min and 1 min ticker for the crypto-currencies to test is not ask you to download them first using `freqtrade download-data`.
already in the `testdata` directory, backtesting will download them For details on downloading, please refer to the [relevant section](#Getting-data-for-backtesting-and-hyperopt) in the documentation.
automatically. Testdata files will not be updated until you specify it.
The result of backtesting will confirm you if your bot has better odds of making a profit than a loss. The result of backtesting will confirm you if your bot has better odds of making a profit than a loss.

View File

@ -30,7 +30,7 @@ These are available from `conftest.py` and can be imported in any test module.
A sample check looks as follows: A sample check looks as follows:
``` python ``` 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): def test_method_to_test(caplog):
method_to_test() method_to_test()

View File

@ -179,5 +179,5 @@ freqtrade plot-profit -p LTC/BTC --db-url sqlite:///tradesv3.sqlite --trade-sou
``` ```
``` bash ``` 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
``` ```

View File

@ -2,9 +2,14 @@
#ignore = #ignore =
max-line-length = 100 max-line-length = 100
max-complexity = 12 max-complexity = 12
exclude =
.git,
__pycache__,
.eggs,
user_data,
[mypy] [mypy]
ignore_missing_imports = True ignore_missing_imports = True
[mypy-freqtrade.tests.*] [mypy-tests.*]
ignore_errors = True ignore_errors = True

View File

@ -891,8 +891,8 @@ def tickers():
@pytest.fixture @pytest.fixture
def result(): def result(testdatadir):
with Path('freqtrade/tests/testdata/UNITTEST_BTC-1m.json').open('r') as data_file: with (testdatadir / 'UNITTEST_BTC-1m.json').open('r') as data_file:
return parse_ticker_dataframe(json.load(data_file), '1m', pair="UNITTEST/BTC", return parse_ticker_dataframe(json.load(data_file), '1m', pair="UNITTEST/BTC",
fill_missing=True) fill_missing=True)

View File

@ -12,7 +12,7 @@ from freqtrade.data.btanalysis import (BT_DATA_COLUMNS,
load_backtest_data, load_trades, load_backtest_data, load_trades,
load_trades_from_db) load_trades_from_db)
from freqtrade.data.history import load_data, load_pair_history 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): def test_load_backtest_data(testdatadir):

View File

@ -3,7 +3,7 @@ import logging
from freqtrade.data.converter import parse_ticker_dataframe, ohlcv_fill_up_missing_data 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.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): def test_dataframe_correct_columns(result):

View File

@ -4,7 +4,7 @@ from pandas import DataFrame
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
from freqtrade.state import RunMode 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): def test_ohlcv(mocker, default_conf, ticker_history):

View File

@ -22,7 +22,7 @@ from freqtrade.data.history import (download_pair_history,
from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange import timeframe_to_minutes
from freqtrade.misc import file_dump_json from freqtrade.misc import file_dump_json
from freqtrade.strategy.default_strategy import DefaultStrategy 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 # Change this if modifying UNITTEST/BTC testdatafile
_BTC_UNITTEST_LENGTH = 13681 _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: 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: def test_load_cached_data_for_updating(mocker) -> None:

View File

@ -14,10 +14,9 @@ from freqtrade import OperationalException
from freqtrade.data.converter import parse_ticker_dataframe from freqtrade.data.converter import parse_ticker_dataframe
from freqtrade.edge import Edge, PairInfo from freqtrade.edge import Edge, PairInfo
from freqtrade.strategy.interface import SellType 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
from freqtrade.tests.optimize import (BTContainer, BTrade, from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe,
_build_backtest_dataframe, _get_frame_time_from_offset)
_get_frame_time_from_offset)
# Cases to be tested: # Cases to be tested:
# 1) Open trade should be removed from the end # 1) Open trade should be removed from the end

View File

@ -6,7 +6,7 @@ import pytest
from freqtrade import (DependencyException, InvalidOrderException, from freqtrade import (DependencyException, InvalidOrderException,
OperationalException, TemporaryError) 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): def test_stoploss_limit_order(default_conf, mocker):

View File

@ -20,7 +20,7 @@ from freqtrade.exchange.exchange import (API_RETRY_COUNT, timeframe_to_minutes,
timeframe_to_prev_date, timeframe_to_prev_date,
timeframe_to_seconds) timeframe_to_seconds)
from freqtrade.resolvers.exchange_resolver import ExchangeResolver 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!! # Make sure to always keep one exchange here which is NOT subclassed!!
EXCHANGES = ['bittrex', 'binance', 'kraken', ] EXCHANGES = ['bittrex', 'binance', 'kraken', ]

View File

@ -3,7 +3,7 @@
from random import randint from random import randint
from unittest.mock import MagicMock 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): def test_buy_kraken_trading_agreement(default_conf, mocker):

View File

@ -8,11 +8,9 @@ from pandas import DataFrame
from freqtrade.data.history import get_timeframe from freqtrade.data.history import get_timeframe
from freqtrade.optimize.backtesting import Backtesting from freqtrade.optimize.backtesting import Backtesting
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
from freqtrade.tests.conftest import patch_exchange from tests.conftest import patch_exchange
from freqtrade.tests.optimize import (BTContainer, BTrade, from tests.optimize import (BTContainer, BTrade, _build_backtest_dataframe,
_build_backtest_dataframe, _get_frame_time_from_offset, tests_ticker_interval)
_get_frame_time_from_offset,
tests_ticker_interval)
# Test 0: Sell with signal sell in candle 3 # Test 0: Sell with signal sell in candle 3
# Test with Stop-loss at 1% # Test with Stop-loss at 1%

View File

@ -22,9 +22,8 @@ from freqtrade.optimize.backtesting import Backtesting
from freqtrade.state import RunMode from freqtrade.state import RunMode
from freqtrade.strategy.default_strategy import DefaultStrategy from freqtrade.strategy.default_strategy import DefaultStrategy
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
from freqtrade.tests.conftest import (get_args, log_has, log_has_re, from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,
patch_exchange, patched_configuration_load_config_file)
patched_configuration_load_config_file)
def trim_dictlist(dict_list, num): def trim_dictlist(dict_list, num):
@ -807,7 +806,7 @@ def test_backtest_record(default_conf, fee, mocker):
assert dur > 0 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'] default_conf['exchange']['pair_whitelist'] = ['UNITTEST/BTC']
async def load_pairs(pair, timeframe, since): async def load_pairs(pair, timeframe, since):
@ -824,7 +823,7 @@ def test_backtest_start_timerange(default_conf, mocker, caplog):
args = [ args = [
'--config', 'config.json', '--config', 'config.json',
'--strategy', 'DefaultStrategy', '--strategy', 'DefaultStrategy',
'--datadir', 'freqtrade/tests/testdata', '--datadir', str(testdatadir),
'backtesting', 'backtesting',
'--ticker-interval', '1m', '--ticker-interval', '1m',
'--timerange', '-100', '--timerange', '-100',
@ -838,7 +837,7 @@ def test_backtest_start_timerange(default_conf, mocker, caplog):
'Parameter -i/--ticker-interval detected ... Using ticker_interval: 1m ...', 'Parameter -i/--ticker-interval detected ... Using ticker_interval: 1m ...',
'Ignoring max_open_trades (--disable-max-market-positions was used) ...', 'Ignoring max_open_trades (--disable-max-market-positions was used) ...',
'Parameter --timerange detected: -100 ...', 'Parameter --timerange detected: -100 ...',
'Using data directory: freqtrade/tests/testdata ...', f'Using data directory: {testdatadir} ...',
'Using stake_currency: BTC ...', 'Using stake_currency: BTC ...',
'Using stake_amount: 0.001 ...', 'Using stake_amount: 0.001 ...',
'Backtesting with data from 2017-11-14T21:17:00+00:00 ' '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) 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'] default_conf['exchange']['pair_whitelist'] = ['UNITTEST/BTC']
async def load_pairs(pair, timeframe, since): async def load_pairs(pair, timeframe, since):
@ -870,7 +869,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog):
args = [ args = [
'--config', 'config.json', '--config', 'config.json',
'--datadir', 'freqtrade/tests/testdata', '--datadir', str(testdatadir),
'backtesting', 'backtesting',
'--ticker-interval', '1m', '--ticker-interval', '1m',
'--timerange', '-100', '--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 ...', 'Parameter -i/--ticker-interval detected ... Using ticker_interval: 1m ...',
'Ignoring max_open_trades (--disable-max-market-positions was used) ...', 'Ignoring max_open_trades (--disable-max-market-positions was used) ...',
'Parameter --timerange detected: -100 ...', 'Parameter --timerange detected: -100 ...',
'Using data directory: freqtrade/tests/testdata ...', f'Using data directory: {testdatadir} ...',
'Using stake_currency: BTC ...', 'Using stake_currency: BTC ...',
'Using stake_amount: 0.001 ...', 'Using stake_amount: 0.001 ...',
'Backtesting with data from 2017-11-14T21:17:00+00:00 ' 'Backtesting with data from 2017-11-14T21:17:00+00:00 '

View File

@ -9,9 +9,8 @@ from freqtrade.edge import PairInfo
from freqtrade.optimize import setup_configuration, start_edge from freqtrade.optimize import setup_configuration, start_edge
from freqtrade.optimize.edge_cli import EdgeCli from freqtrade.optimize.edge_cli import EdgeCli
from freqtrade.state import RunMode from freqtrade.state import RunMode
from freqtrade.tests.conftest import (get_args, log_has, log_has_re, from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,
patch_exchange, patched_configuration_load_config_file)
patched_configuration_load_config_file)
def test_setup_configuration_without_arguments(mocker, default_conf, caplog) -> None: def test_setup_configuration_without_arguments(mocker, default_conf, caplog) -> None:

View File

@ -1,13 +1,12 @@
# pragma pylint: disable=missing-docstring,W0212,C0103 # pragma pylint: disable=missing-docstring,W0212,C0103
import os
from datetime import datetime from datetime import datetime
from pathlib import Path
from unittest.mock import MagicMock, PropertyMock from unittest.mock import MagicMock, PropertyMock
import pandas as pd import pandas as pd
import pytest import pytest
from arrow import Arrow from arrow import Arrow
from filelock import Timeout from filelock import Timeout
from pathlib import Path
from freqtrade import OperationalException from freqtrade import OperationalException
from freqtrade.data.converter import parse_ticker_dataframe 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 import DefaultHyperOpts
from freqtrade.optimize.default_hyperopt_loss import DefaultHyperOptLoss from freqtrade.optimize.default_hyperopt_loss import DefaultHyperOptLoss
from freqtrade.optimize.hyperopt import Hyperopt 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.state import RunMode
from freqtrade.strategy.interface import SellType from freqtrade.strategy.interface import SellType
from freqtrade.tests.conftest import (get_args, log_has, log_has_re, from tests.conftest import (get_args, log_has, log_has_re, patch_exchange,
patch_exchange, patched_configuration_load_config_file)
patched_configuration_load_config_file)
@pytest.fixture(scope='function') @pytest.fixture(scope='function')
@ -47,14 +46,14 @@ def hyperopt_results():
# Functions for recurrent object patching # 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* When creating trials, mock the hyperopt Trials so that *by default*
- we don't create any pickle'd files in the filesystem - we don't create any pickle'd files in the filesystem
- we might have a pickle'd file so make sure that we return - we might have a pickle'd file so make sure that we return
false when looking for it 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)) mocker.patch.object(Path, "is_file", MagicMock(return_value=False))
stat_mock = MagicMock() stat_mock = MagicMock()
@ -356,23 +355,23 @@ def test_no_log_if_loss_does_not_improve(hyperopt, caplog) -> None:
assert caplog.record_tuples == [] assert caplog.record_tuples == []
def test_save_trials_saves_trials(mocker, hyperopt, caplog) -> None: def test_save_trials_saves_trials(mocker, hyperopt, testdatadir, caplog) -> None:
trials = create_trials(mocker, hyperopt) trials = create_trials(mocker, hyperopt, testdatadir)
mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None) mock_dump = mocker.patch('freqtrade.optimize.hyperopt.dump', return_value=None)
hyperopt.trials = trials hyperopt.trials = trials
hyperopt.save_trials() hyperopt.save_trials()
trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle') trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
assert log_has("Saving 1 evaluations to '{}'".format(trials_file), caplog) assert log_has(f"Saving 1 evaluations to '{trials_file}'", caplog)
mock_dump.assert_called_once() mock_dump.assert_called_once()
def test_read_trials_returns_trials_file(mocker, hyperopt, caplog) -> None: def test_read_trials_returns_trials_file(mocker, hyperopt, testdatadir, caplog) -> None:
trials = create_trials(mocker, hyperopt) trials = create_trials(mocker, hyperopt, testdatadir)
mock_load = mocker.patch('freqtrade.optimize.hyperopt.load', return_value=trials) mock_load = mocker.patch('freqtrade.optimize.hyperopt.load', return_value=trials)
hyperopt_trial = hyperopt.read_trials() hyperopt_trial = hyperopt.read_trials()
trials_file = os.path.join('freqtrade', 'tests', 'optimize', 'ut_trials.pickle') trials_file = testdatadir / 'optimize' / 'ut_trials.pickle'
assert log_has("Reading Trials from '{}'".format(trials_file), caplog) assert log_has(f"Reading Trials from '{trials_file}'", caplog)
assert hyperopt_trial == trials assert hyperopt_trial == trials
mock_load.assert_called_once() mock_load.assert_called_once()

View File

@ -5,7 +5,7 @@ from unittest.mock import MagicMock, PropertyMock
from freqtrade import OperationalException from freqtrade import OperationalException
from freqtrade.constants import AVAILABLE_PAIRLISTS from freqtrade.constants import AVAILABLE_PAIRLISTS
from freqtrade.resolvers import PairListResolver from freqtrade.resolvers import PairListResolver
from freqtrade.tests.conftest import get_patched_freqtradebot from tests.conftest import get_patched_freqtradebot
import pytest import pytest
# whitelist, blacklist # whitelist, blacklist

View File

@ -8,7 +8,7 @@ import pytest
from requests.exceptions import RequestException from requests.exceptions import RequestException
from freqtrade.rpc.fiat_convert import CryptoFiat, CryptoToFiatConverter 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(): def test_pair_convertion_object():

View File

@ -14,7 +14,7 @@ from freqtrade.persistence import Trade
from freqtrade.rpc import RPC, RPCException from freqtrade.rpc import RPC, RPCException
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
from freqtrade.state import State 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 # Functions for recurrent object patching

View File

@ -13,9 +13,7 @@ from freqtrade.__init__ import __version__
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.rpc.api_server import BASE_URI, ApiServer from freqtrade.rpc.api_server import BASE_URI, ApiServer
from freqtrade.state import State from freqtrade.state import State
from freqtrade.tests.conftest import (get_patched_freqtradebot, log_has, from tests.conftest import get_patched_freqtradebot, log_has, patch_get_signal
patch_get_signal)
_TEST_USER = "FreqTrader" _TEST_USER = "FreqTrader"
_TEST_PASS = "SuperSecurePassword1!" _TEST_PASS = "SuperSecurePassword1!"

View File

@ -4,7 +4,7 @@ import logging
from unittest.mock import MagicMock from unittest.mock import MagicMock
from freqtrade.rpc import RPCMessageType, RPCManager 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: def test__init__(mocker, default_conf) -> None:

View File

@ -21,8 +21,8 @@ from freqtrade.rpc import RPCMessageType
from freqtrade.rpc.telegram import Telegram, authorized_only from freqtrade.rpc.telegram import Telegram, authorized_only
from freqtrade.state import State from freqtrade.state import State
from freqtrade.strategy.interface import SellType 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, patch_exchange,
patch_exchange, patch_get_signal) patch_get_signal)
class DummyCls(Telegram): class DummyCls(Telegram):

View File

@ -8,7 +8,7 @@ from requests import RequestException
from freqtrade.rpc import RPCMessageType from freqtrade.rpc import RPCMessageType
from freqtrade.rpc.webhook import Webhook from freqtrade.rpc.webhook import Webhook
from freqtrade.strategy.interface import SellType 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: def get_webhook_dict() -> dict:

View File

@ -1,19 +1,8 @@
import json
import pytest
from pandas import DataFrame from pandas import DataFrame
from freqtrade.data.converter import parse_ticker_dataframe
from freqtrade.strategy.default_strategy import DefaultStrategy 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(): def test_default_strategy_structure():
assert hasattr(DefaultStrategy, 'minimal_roi') assert hasattr(DefaultStrategy, 'minimal_roi')
assert hasattr(DefaultStrategy, 'stoploss') assert hasattr(DefaultStrategy, 'stoploss')

View File

@ -10,7 +10,7 @@ from freqtrade.configuration import TimeRange
from freqtrade.data.converter import parse_ticker_dataframe from freqtrade.data.converter import parse_ticker_dataframe
from freqtrade.data.history import load_tickerdata_file from freqtrade.data.history import load_tickerdata_file
from freqtrade.persistence import Trade 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 from freqtrade.strategy.default_strategy import DefaultStrategy
# Avoid to reinit the same object again and again # Avoid to reinit the same object again and again

View File

@ -12,12 +12,12 @@ from pandas import DataFrame
from freqtrade import OperationalException from freqtrade import OperationalException
from freqtrade.resolvers import StrategyResolver from freqtrade.resolvers import StrategyResolver
from freqtrade.strategy.interface import IStrategy 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(): def test_search_strategy():
default_config = {} 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( s, _ = StrategyResolver._search_object(
directory=default_location, directory=default_location,

View File

@ -10,7 +10,8 @@ import pytest
from jsonschema import Draft4Validator, ValidationError, validate from jsonschema import Draft4Validator, ValidationError, validate
from freqtrade import OperationalException, constants 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.check_exchange import check_exchange
from freqtrade.configuration.config_validation import validate_config_schema from freqtrade.configuration.config_validation import validate_config_schema
from freqtrade.configuration.directory_operations import (create_datadir, 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.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL
from freqtrade.loggers import _set_loggers from freqtrade.loggers import _set_loggers
from freqtrade.state import RunMode from freqtrade.state import RunMode
from freqtrade.tests.conftest import (log_has, log_has_re, from tests.conftest import (log_has, log_has_re,
patched_configuration_load_config_file) patched_configuration_load_config_file)
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def all_conf(): 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) print(config_file)
conf = load_config_file(str(config_file)) conf = load_config_file(str(config_file))
return conf return conf

View File

@ -16,13 +16,12 @@ from freqtrade.data.dataprovider import DataProvider
from freqtrade.freqtradebot import FreqtradeBot from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.persistence import Trade from freqtrade.persistence import Trade
from freqtrade.rpc import RPCMessageType 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.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 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: def patch_RPCManager(mocker) -> MagicMock:

View File

@ -10,9 +10,9 @@ from freqtrade.configuration import Arguments
from freqtrade.freqtradebot import FreqtradeBot from freqtrade.freqtradebot import FreqtradeBot
from freqtrade.main import main from freqtrade.main import main
from freqtrade.state import State 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 freqtrade.worker import Worker
from tests.conftest import (log_has, patch_exchange,
patched_configuration_load_config_file)
def test_parse_args_backtesting(mocker) -> None: def test_parse_args_backtesting(mocker) -> None:

View File

@ -8,7 +8,7 @@ from sqlalchemy import create_engine
from freqtrade import OperationalException, constants from freqtrade import OperationalException, constants
from freqtrade.persistence import Trade, clean_dry_run_db, init 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): def create_mock_trades(fee):

View File

@ -19,7 +19,7 @@ from freqtrade.plot.plotting import (add_indicators, add_profit,
generate_profit_graph, init_plotscript, generate_profit_graph, init_plotscript,
plot_profit, plot_trades, store_plot_file) plot_profit, plot_trades, store_plot_file)
from freqtrade.strategy.default_strategy import DefaultStrategy 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): def fig_generating_mock(fig, *args, **kwargs):

View File

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, PropertyMock
import pytest import pytest
from freqtrade.state import RunMode 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, from freqtrade.utils import (setup_utils_configuration, start_create_userdir,
start_download_data, start_list_exchanges) start_download_data, start_list_exchanges)

View File

@ -1,5 +1,5 @@
# pragma pylint: disable=missing-docstring # 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 from unittest.mock import MagicMock