Best Python code snippet using avocado_python
generate-api-toc.py
Source: generate-api-toc.py
...68{% endfor %}69"""70template = jinja2.Template(TEMPLATE)71# http://stackoverflow.com/a/15723105/31516872def get_submodules(mod):73 modules = []74 for loader, module_name, is_pkg in pkgutil.iter_modules(mod.__path__):75 if module_name.startswith("test_"):76 continue77 mod_name = mod.__name__ + "." + module_name78 # print("Found module ", mod_name)79 module = pkgutil.importlib.import_module(mod_name)80 modules.append(module)81 results = []82 for mod in modules:83 try:84 intro = mod.__doc__.split("\n")[0]85 except Exception as exc:86 sys.exit("Module missing a docstring: {mod}".format(mod=mod))87 results.append((mod.__name__, intro))88 return results89modules = {90 'core': get_submodules(websauna.system),91 'utils': get_submodules(websauna.utils),92 'testing': get_submodules(websauna.tests)93}...
.test0.py
Source: .test0.py
...28 if isinstance(x, ast.ImportFrom):29 name = x.module30 if (mod := sys.modules.get(name)) and not is_builtin(name, mod):31 yield name32def get_submodules(mod, visited=None, results=None):33 if results is None:34 results = set()35 if visited is None:36 visited = set()37 for name in get_imports_from_module(mod):38 if name in visited:39 continue40 visited.add(name)41 results.add(name)42 for x in get_imports_from_module(sys.modules[name]):43 results.add(x)44 get_submodules(sys.modules[x], visited, results)45 return results46pprint(list(get_submodules(beartype)))...
utils.py
Source: utils.py
...4from django.template import loaders5MODULE_EXTENSIONS = tuple([suffix[0] for suffix in imp.get_suffixes()])6def get_django_template_loaders():7 return [(loader.__name__.rsplit('.',1)[1], loader) 8 for loader in get_submodules(loaders)9 if hasattr(loader, 'load_template_source')]10 11def get_submodules(package):12 submodules = ("%s.%s" % (package.__name__, module)13 for module in package_contents(package))14 return [__import__(module, {}, {}, [module.rsplit(".", 1)[-1]]) 15 for module in submodules]16def package_contents(package):17 package_path = dirname(loaders.__file__)18 contents = set([splitext(module)[0]19 for module in listdir(package_path)20 if module.endswith(MODULE_EXTENSIONS)])...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!