How to use import_test_class method in Testify

Best Python code snippet using Testify_python

ve_test.py

Source:ve_test.py Github

copy

Full Screen

...71 self.useUXApi = False72 #initialization73 self.useAssertMgr = useAssertMgr74 self.configuration = configuration(self)75 self.logger = self.import_test_class("tests_framework.logger.logger", "Logger")76 self.milestones = self.import_test_class("tests_framework.milestones.milestones_client", "MilestonesClient")77 self.ctap_data_provider = self.import_test_class("tests_framework.ctap_util.ctap_data_provider", "CtapDataProvider")78 self.ui = self.import_test_class("tests_framework.ve_tests.ui", "VeTestUI")79 self.performance = self.import_test_class("tests_framework.ve_tests.performance", "performance")80 self.requests = self.import_test_class("tests_framework.ve_tests.ve_requests", "VeTestRequests")81 self.mirror = self.import_test_class("tests_framework.ve_tests.mirror", "VeTestMirror")82 #Assert Mgr support83 self.useAssertMgr = useAssertMgr84 if self.useAssertMgr is True:85 self.assertmgr = AssertMgr(self)86 #Profile support87 self.profile = pytest.config.getoption("--profile")88 if not self.profile:89 self.profile = self.get_config("profile", "name", None)90 if self.profile:91 self.log_assert(self.profile in self.configuration, "Cannot find '" + self.profile + "' in configuration file")92 self.log("Using profile: '" + self.profile + "'")93 if 'he' not in self.configuration:94 self.configuration['he'] = self.get_config("he")95 #Verbose support96 self.verbose = self.get_config("general", "verbose", "False", "True")97 if self.verbose:98 self.logger.setLevel(logging.INFO)99 self.logger.setLevel(logging.WARNING, "requests")100 #Device id101 self.device_id = self.get_config("device", "deviceId", None)102 #Device ip103 self.device_ip = self.get_config("device", "ip", None)104 #Platform105 self.platform = pytest.config.getoption("--platform")106 if not self.platform:107 self.platform = self.get_config("appium", "platformName", "iOS")108 #He109 self.is_fixed_household = self.get_config("he", "fixedHousehold", "False", "True")110 self.lab = self.get_config("he", "lab", "False")111 self.is_dummy = self.lab == "dummy"112 self.is_local_ctap = self.get_config("he", "local_ctap", "False", "True")113 #Dynamic114 self.dynamic = self.get_config("general", "dynamic", "False", "True")115 self.dynamicDevice = False116 self.dynamicIp = False117 if self.dynamic:118 self.dynamicDevice = True119 self.dynamicIp = True120 if not self.device_ip:121 self.dynamicIp = True122 if not self.device_id:123 self.dynamicDevice = True124 #General125 self.screenshotDir = self.get_config("general", "screenshotDir")126 self.cacheDir = self.get_config("general", "cacheDir")127 self.project = self.get_config("general", "project", "KD").upper()128 self.webApp = self.get_config("general", "webApp")129 self.browser = self.get_config("general", "browser")130 self.manage_app = self.get_config("general", "manageApp", "True", "True")131 self.install_manage = self.get_config("general", "installManage", "True", "True")132 self.use_web_login = self.get_config("general", "useWebLogin", "True", "True")133 self.ignoreLogin = self.get_config("general", "ignoreLogin", "False", "True")134 self.dynamicDevice = self.get_config("general", "dynamicDevice", self.toBoolString(self.dynamicDevice), "True")135 self.dynamicIp = self.get_config("general", "dynamicIp", self.toBoolString(self.dynamicIp), "True")136 self.stayOnAssert = self.get_config("general", "stayOnAssert", "False", "True")137 self.sayIsActive = self.get_config("general", "sayIsActive", "False", "True")138 self.vgwUtils = vgwUtils139 if self.vgwUtils:140 self.vgwUtils = self.get_config("general", "vgwUtils", "False", "True")141 self.useAltRegion = self.get_config("general", "useAltRegion", "True" if self.project=="NET" else "False", "True")142 self.takeScreenshot = self.get_config("general", "takeSnapshot", "True")143 self.overrideArgs = self.get_config("general", "override", "True", "True")144 self.login_wait = self.get_config("general", "loginWait")145 self.shotByShot = self.get_config("general", "shotByShot", "False", "True")146 self.he_timeout = self.get_config("general", "heTimeout", HE_INIT_TIMEOUT)147 self.waitAfterLaunch = self.get_config("general", "waitAfterLaunch")148 self.vgwServerName = self.get_config("CI_VARIABLES", "vlan.name", useProfile=False)149 self.platformFolder = self.get_config("general", "platformFolder", "False", "True")150 self.useCache = self.get_config("general", "useCache", "False", "True")151 self.skipDeviceCheck = self.get_config("general", "skipDeviceCheck", "False", "True")152 self.useUXApi = self.get_config("general","useUXApi","False", "True")153 if self.vgwServerName:154 if "openstack-lwr-han" in self.vgwServerName:155 self.useAltRegion = True156 #Set project type157 if self.project != "KD":158 if "androidtv" in self.get_config("appium", "appPackage", "com.cisco.videoeverywhere3.nexplayer"):159 self.project_type = "KSTB"160 self.milestones = self.import_test_class("tests_framework.milestones.milestones_kpi_client", "MilestonesKpiClient")161 else:162 self.project_type = "K"163 else:164 self.project_type = "KD"165 if self.useAssertMgr is True:166 self.assertmgr = AssertMgr(self)167 #KD live idp168 self.liveIdp = self.get_config("general", "liveIdp", "False", "True")169 #Screens170 self.screens = self.import_test_class("tests_framework.ui_building_blocks.screens", "Screens")171 self.screen = self.import_test_class("tests_framework.ui_building_blocks.screen", "Screen")172 #Head end configuration173 if self.vgwUtils:174 self.log("Retreiving vgw utils he configuration...")175 self.is_dummy = False #Override since there is no dummy in vgw utils mode176 self.setupHeConfigurationVgwUtils()177 else:178 self.log("Retreiving standard he configuration...")179 self.setupHeConfiguration()180 self.log("Retrieved he configuration")181 #Platform specifics182 if self.platform == "Android":183 self.appium = self.import_test_class("tests_framework.appium.appium_wrapper", "AndroidWrapper")184 if self.is_dummy:185 self.android_mock_server = self.import_test_class("tests_framework.CTAP_mock.android.mock_server", "AndroidMockServer")186 elif self.platform == "iOS":187 self.appium = self.import_test_class("tests_framework.appium.appium_wrapper", "IosWrapper")188 elif self.platform == "PC":189 self.appium = self.import_test_class("tests_framework.appium.appium_wrapper", "PcWrapper")190 self.he_utils = self.import_test_class("tests_framework.he_utils.he_utils", "HeUtils")191 self.cmdc_queries = self.import_test_class("tests_framework.he_utils.cmdc_querys", "CMDC")192 self.ta_queries = self.import_test_class("tests_framework.he_utils.ta_queries", "TA")193 if not self.skipDeviceCheck:194 if self.dynamicDevice:195 #Get dynamic device id196 deviceId = self.appium.getDeviceId()197 if deviceId:198 self.device_id = deviceId199 if self.dynamicIp:200 #Get dynamic device ip201 deviceIp = self.appium.getDeviceIp()202 if deviceIp:203 self.device_ip = deviceIp204 self.log("device identifier: " + str(self.device_id) + " ip: " + str(self.device_ip))205 self.assets = self.import_test_class("tests_framework.ve_tests.assets", "VeTestAssets")206 self.sessionAsset = self.import_test_class("tests_framework.ve_tests.assets", "SeasonAsset")207 self.cmdc = self.import_test_class("tests_framework.he_utils.cmdc_querys", "CMDC")208 if self.use_appium:209 self.appium.start_server()210 if not self.skipDeviceCheck:211 self.appium.reset_app()212 def retrieve_he_info(self, preload=None):213 try:214 self.log(("Starting async head end setup..."))215 self.he_utils.preload = preload216 self.he_utils.thread.start()217 except Exception as e:218 self.log_assert(False, "Failed to init HeUtils(), error=%s" % e)219 self.log('waiting to be ready \n')220 self.he_utils.thread.join(self.he_timeout)221 self.log_assert(self.he_utils.heUtilsFinished, "HE Actions failed with exception: " + str(self.he_utils.exception))222 if self.useUXApi :223 self.he_utils.doCtapInit()224 def import_test_class(self, path, name):225 logging.info("Loading module: " + path + " class: " + name)226 module = importlib.import_module(path)227 myclass = getattr(module, name)228 instance = myclass(self)229 return instance230 def toBoolString(self, boolean):231 if boolean:232 return "True"233 else:234 return "False"235 def get_config(self, group, name=None, default_value=None, compare_value=None, useProfile=True):236 if name:237 name = name.rstrip()238 name = name.lstrip()...

Full Screen

Full Screen

class_loader_test.py

Source:class_loader_test.py Github

copy

Full Screen

1import os2from typing import List3import unittest4import sys5sys.path.append('../')6print(sys.path)7class TestClass:8 def shori(self):9 return "shori"10class TestClassLoder(unittest.TestCase):11 """動的モジュールローダーのテストクラス12 """13 @classmethod14 def setUpClass(cls):15 os.environ.setdefault('SETTINGS_PATH', 'todo_scratch.bk_app.settings')16 def test_class_loader(self):17 """動的モジュールからクラス生成テスト18 """19 print("-----{0}-----".format("test_class_loader"))20 from todo_scratch.bk_base.util.class_loader_util import get_module_by_file_path21 BASE_DIR = os.path.dirname(os.path.abspath(__file__))22 print(BASE_DIR)23 import_cls = get_module_by_file_path('TestClass', BASE_DIR + '/class_loader_test.py')24 # 動的モジュールからクラス生成25 import_test_class = import_cls.TestClass()26 # 静的モジュールからクラス生成27 test_class: TestClass = TestClass()28 self.assertEqual(test_class.shori(), import_test_class.shori())29 def test_route_loder(self):30 print("-----{0}-----".format("test_route_loder"))31 from todo_scratch.bk_base.util.class_loader_util import get_module_by_route32 urlpatterns = get_module_by_route('urlpatterns', 'todo_scratch.bk_app.urls')33 print(urlpatterns)34 self.assertEqual(3, 3)35 def test_import_module_by_route(self):36 print("-----{0}-----".format("test_import_module_by_route"))37 from todo_scratch.bk_base.util.class_loader_util import get_module_by_full_route38 from todo_scratch.bk_base.util.settings_util import get_member_by_settings39 middlewares: List[str] = get_member_by_settings("MIDDLEWARES")40 for middleware in middlewares:41 module = get_module_by_full_route(middleware)42 print(module)43 self.assertEqual(3, 3)44if __name__ == '__main__':45 print("start test")...

Full Screen

Full Screen

test_rerunner.py

Source:test_rerunner.py Github

copy

Full Screen

...37 ]38 for class_path, tests in groupby(tests, lambda test: test[:2]):39 methods = [test.method for test in tests]40 module, cls = class_path41 cls = test_discovery.import_test_class(module, cls)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testify automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful