diff --git a/tests/test_import_all.py b/tests/test_import_all.py index 6ebe6e78..3175aec5 100644 --- a/tests/test_import_all.py +++ b/tests/test_import_all.py @@ -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): @@ -34,6 +41,7 @@ class GatewayImportTest(unittest.TestCase): 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 @@ -60,7 +68,7 @@ class GatewayImportTest(unittest.TestCase): 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