Best Python code snippet using behave
_registry.py
Source:_registry.py
...54 """55 if ":" not in scoped_class_name:56 message = 'REQUIRE: "module:class", but was: "%s"' % scoped_class_name57 raise ValueError(message)58 module_name, class_name = parse_scoped_name(scoped_class_name)59 formatter_module = load_module(module_name)60 formatter_class = getattr(formatter_module, class_name, None)61 if formatter_class is None:62 raise ImportError("CLASS NOT FOUND: %s" % scoped_class_name)63 return formatter_class64def select_formatter_class(formatter_name):65 """Resolve the formatter class by:66 * using one of the registered ones67 * loading a user-specified formatter class (like: my.module_name:MyClass)68 :param formatter_name: Name of the formatter or scoped name (as string).69 :return: Formatter class70 :raises: LookupError, if not found.71 :raises: ImportError, if a user-specific formatter class cannot be loaded.72 :raises: ValueError, if formatter name is invalid....
importer.py
Source:importer.py
...5"""6from __future__ import absolute_import7import importlib8from behave._types import Unknown9def parse_scoped_name(scoped_name):10 """11 SCHEMA: my.module_name:MyClassName12 EXAMPLE:13 behave.formatter.plain:PlainFormatter14 """15 scoped_name = scoped_name.strip()16 if "::" in scoped_name:17 # -- ALTERNATIVE: my.module_name::MyClassName18 scoped_name = scoped_name.replace("::", ":")19 module_name, object_name = scoped_name.rsplit(":", 1)20 return module_name, object_name21def load_module(module_name):22 return importlib.import_module(module_name)23class LazyObject(object):24 """25 Provides a placeholder for an object that should be loaded lazily.26 """27 def __init__(self, module_name, object_name=None):28 if ":" in module_name and not object_name:29 module_name, object_name = parse_scoped_name(module_name)30 assert ":" not in module_name31 self.module_name = module_name32 self.object_name = object_name33 self.resolved_object = None34 def __get__(self, obj=None, type=None): # pylint: disable=redefined-builtin35 """36 Implement descriptor protocol,37 useful if this class is used as attribute.38 :return: Real object (lazy-loaded if necessary).39 :raise ImportError: If module or object cannot be imported.40 """41 __pychecker__ = "unusednames=obj,type"42 resolved_object = None43 if not self.resolved_object:...
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!!