From 6a7b9e139d979c1be941851e29bf6ad7fa632283 Mon Sep 17 00:00:00 2001 From: nanoric Date: Sun, 14 Apr 2019 05:58:18 -0400 Subject: [PATCH] =?UTF-8?q?[Mod]=20=E4=BF=AE=E6=AD=A3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 + tests/test_all.py | 17 ++++++++++++++--- vnpy/app/cta_strategy/backtesting.py | 3 +-- vnpy/trader/database/database.py | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d38b8fed..32672af3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ services: script: # todo: use python unittest + - pip install psycopg2 mongoengine pymysql # we should support all database in test environment - cd tests; source travis_env.sh; python test_all.py matrix: diff --git a/tests/test_all.py b/tests/test_all.py index e824ff21..e5f8b6c2 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -1,10 +1,10 @@ # tests/runner.py import unittest +import app # import your test modules import test_import_all import trader -import app # initialize the test suite loader = unittest.TestLoader() @@ -15,6 +15,17 @@ suite.addTests(loader.loadTestsFromModule(test_import_all)) suite.addTests(loader.loadTestsFromModule(trader)) suite.addTests(loader.loadTestsFromModule(app)) + # initialize a runner, pass it your suite and run it -runner = unittest.TextTestRunner(verbosity=3) -result = runner.run(suite) +def main(): + runner = unittest.TextTestRunner(verbosity=3) + result = runner.run(suite) + return result + + +if __name__ == '__main__': + result = main() + if result.failures: + exit(1) + else: + exit(0) diff --git a/vnpy/app/cta_strategy/backtesting.py b/vnpy/app/cta_strategy/backtesting.py index e4661107..9263ed2a 100644 --- a/vnpy/app/cta_strategy/backtesting.py +++ b/vnpy/app/cta_strategy/backtesting.py @@ -14,7 +14,7 @@ from vnpy.trader.constant import (Direction, Offset, Exchange, Interval, Status) from vnpy.trader.database import database_manager from vnpy.trader.object import OrderData, TradeData, BarData, TickData -from vnpy.trader.utility import round_to_pricetick, extract_vt_symbol +from vnpy.trader.utility import round_to_pricetick from .base import ( BacktestingMode, @@ -990,4 +990,3 @@ def load_tick_data( return database_manager.load_tick_data( symbol, exchange, start, end ) - diff --git a/vnpy/trader/database/database.py b/vnpy/trader/database/database.py index 06077383..ec765e8d 100644 --- a/vnpy/trader/database/database.py +++ b/vnpy/trader/database/database.py @@ -4,8 +4,8 @@ from enum import Enum from typing import Sequence, TYPE_CHECKING if TYPE_CHECKING: - from vnpy.trader.constant import Interval, Exchange - from vnpy.trader.object import BarData, TickData + from vnpy.trader.constant import Interval, Exchange # noqa + from vnpy.trader.object import BarData, TickData # noqa class Driver(Enum):