[Add] skip some tests if module not built
This commit is contained in:
parent
9dab75f28a
commit
1b8152efc7
@ -8,6 +8,13 @@ def check_env(key: str, default=None):
|
|||||||
return environ.get(key, default)
|
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
|
# noinspection PyUnresolvedReferences,PyMethodMayBeStatic
|
||||||
class CoreImportTest(unittest.TestCase):
|
class CoreImportTest(unittest.TestCase):
|
||||||
|
|
||||||
@ -34,6 +41,7 @@ class GatewayImportTest(unittest.TestCase):
|
|||||||
from vnpy.gateway.bitmex import BitmexGateway
|
from vnpy.gateway.bitmex import BitmexGateway
|
||||||
|
|
||||||
@unittest.skipIf(platform.system() == "Darwin", "Not supported yet under osx")
|
@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):
|
def test_import_ctp(self):
|
||||||
from vnpy.gateway.ctp import CtpGateway
|
from vnpy.gateway.ctp import CtpGateway
|
||||||
|
|
||||||
@ -60,7 +68,7 @@ class GatewayImportTest(unittest.TestCase):
|
|||||||
from vnpy.gateway.ib import IbGateway
|
from vnpy.gateway.ib import IbGateway
|
||||||
|
|
||||||
@unittest.skipIf(platform.system() == "Darwin", "Not supported yet under osx")
|
@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):
|
def test_import_oes(self):
|
||||||
from vnpy.gateway.oes import OesGateway
|
from vnpy.gateway.oes import OesGateway
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user