Skip to content

Commit

Permalink
[Add] skip some tests if module not built
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoric committed Aug 8, 2019
1 parent 9dab75f commit 1b8152e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_import_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ def check_env(key: str, default=None):
return environ.get(key, default)


def skip_if_module_not_built(env_key: str):
return unittest.skipIf(
check_env(key=env_key) == '0',
f"Skip because of {env_key}==0",
)


# noinspection PyUnresolvedReferences,PyMethodMayBeStatic
class CoreImportTest(unittest.TestCase):

Expand All @@ -34,6 +41,7 @@ def test_import_bitmex(self):
from vnpy.gateway.bitmex import BitmexGateway

@unittest.skipIf(platform.system() == "Darwin", "Not supported yet under osx")
@skip_if_module_not_built(env_key="VNPY_BUILD_CTP")
def test_import_ctp(self):
from vnpy.gateway.ctp import CtpGateway

Expand All @@ -60,7 +68,7 @@ def test_import_ib(self):
from vnpy.gateway.ib import IbGateway

@unittest.skipIf(platform.system() == "Darwin", "Not supported yet under osx")
@unittest.skipIf(check_env('VNPY_BUILD_OES') == '0', "Skip because of VNPY_BUILD_OES==0")
@skip_if_module_not_built(env_key="VNPY_BUILD_OES")
def test_import_oes(self):
from vnpy.gateway.oes import OesGateway

Expand Down

0 comments on commit 1b8152e

Please sign in to comment.