Fix tests run in random order (#599)
* allow tests to run in random mode * Fix random test mode for fiat-convert * allow random test execution in persistence * fix pep8 styling * use "usefixtures" to prevent pylint "unused parameter" message * add pytest-random-order to travis
This commit is contained in:
@@ -8,6 +8,11 @@ from freqtrade.exchange import Exchanges
|
||||
from freqtrade.persistence import Trade, init, clean_dry_run_db
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def init_persistence(default_conf):
|
||||
init(default_conf)
|
||||
|
||||
|
||||
def test_init_create_session(default_conf, mocker):
|
||||
mocker.patch.dict('freqtrade.persistence._CONF', default_conf)
|
||||
|
||||
@@ -90,6 +95,7 @@ def test_init_prod_db(default_conf, mocker):
|
||||
os.rename(prod_db_swp, prod_db)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_update_with_bittrex(limit_buy_order, limit_sell_order):
|
||||
"""
|
||||
On this test we will buy and sell a crypto currency.
|
||||
@@ -144,6 +150,7 @@ def test_update_with_bittrex(limit_buy_order, limit_sell_order):
|
||||
assert trade.close_date is not None
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_calc_open_close_trade_price(limit_buy_order, limit_sell_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
@@ -166,6 +173,7 @@ def test_calc_open_close_trade_price(limit_buy_order, limit_sell_order):
|
||||
assert trade.calc_profit_percent() == 0.06201057
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_calc_close_trade_price_exception(limit_buy_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
@@ -179,6 +187,7 @@ def test_calc_close_trade_price_exception(limit_buy_order):
|
||||
assert trade.calc_close_trade_price() == 0.0
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_update_open_order(limit_buy_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
@@ -201,6 +210,7 @@ def test_update_open_order(limit_buy_order):
|
||||
assert trade.close_date is None
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_update_invalid_order(limit_buy_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
@@ -213,6 +223,7 @@ def test_update_invalid_order(limit_buy_order):
|
||||
trade.update(limit_buy_order)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_calc_open_trade_price(limit_buy_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
@@ -230,6 +241,7 @@ def test_calc_open_trade_price(limit_buy_order):
|
||||
assert trade.calc_open_trade_price(fee=0.003) == 0.001003000
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_calc_close_trade_price(limit_buy_order, limit_sell_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
@@ -251,6 +263,7 @@ def test_calc_close_trade_price(limit_buy_order, limit_sell_order):
|
||||
assert trade.calc_close_trade_price(fee=0.005) == 0.0010619972
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_calc_profit(limit_buy_order, limit_sell_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
@@ -281,6 +294,7 @@ def test_calc_profit(limit_buy_order, limit_sell_order):
|
||||
assert trade.calc_profit(fee=0.003) == 0.00006163
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_calc_profit_percent(limit_buy_order, limit_sell_order):
|
||||
trade = Trade(
|
||||
pair='BTC_ETH',
|
||||
|
||||
Reference in New Issue
Block a user