How to use _create_module_and_parents method in autotest

Best Python code snippet using autotest_python

setup_modules.py

Source:setup_modules.py Github

copy

Full Screen

...14 """15 module = new.module(name)16 sys.modules[name] = module17 return module18def _create_module_and_parents(name):19 """20 Create a module, and all the necessary parents and add them to sys.modules.21 :param name: Module name, such as 'autptest.client'.22 """23 parts = name.split(".")24 # frist create the top-level module25 parent = _create_module(parts[0])26 created_parts = [parts[0]]27 parts.pop(0)28 # now, create any remaining child modules29 while parts:30 child_name = parts.pop(0)31 module = new.module(child_name)32 setattr(parent, child_name, module)33 created_parts.append(child_name)34 sys.modules[".".join(created_parts)] = module35 parent = module36def import_module(module, from_where):37 """38 Equivalent to 'from from_where import module'39 :param module: Module name40 :param from_where: Package from where the module is being imported.41 :return: the corresponding module42 """43 from_module = __import__(from_where, globals(), locals(), [module])44 return getattr(from_module, module)45def setup(base_path, root_module_name="caliper"):46 """47 Setup a library namespace, with the appropriate top root module name.48 Perform all the necessary setup so that all the packages at 'base_path' can49 be imported via 'import root_module_name,package'50 :param base_path: Base path for the module51 :parma root_module_name: Top level name for the module52 """53 if sys.modules.has_key(root_module_name):54 return55 _create_module_and_parents(root_module_name)56 imp.load_package(root_module_name, base_path)57 # allow locally installed third party packages to be found....

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 autotest 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