Best Python code snippet using localstack_python
_base.py
Source:_base.py
...70 try:71 loader = self._get_loader_class(self._get_extension_loader_mapping(), extension)(72 self.source73 )74 return self._post_create(loader, extension=extension)75 except LoaderNotFoundError as e:76 raise LoaderNotFoundError(77 "\n".join(78 [79 f"{e.args[0]:s} (unknown extension).",80 "",81 "acceptable extensions are: {}.".format(", ".join(self.get_extensions())),82 f"actual: '{extension}'",83 ]84 )85 )86 def _create_from_format_name(self, format_name):87 try:88 loader = self._get_loader_class(self._get_format_name_loader_mapping(), format_name)(89 self.source90 )91 return self._post_create(loader, format_name=format_name)92 except LoaderNotFoundError as e:93 raise LoaderNotFoundError(94 "\n".join(95 [96 f"{e.args[0]:s} (unknown format name).",97 "acceptable format names are: {}.".format(98 ", ".join(self.get_format_names())99 ),100 ]101 )102 )103 def _post_create(self, loader, **kwargs):104 loader.encoding = self._encoding105 if loader.format_name == "csv" and kwargs.get("format_name") == "ssv":106 loader.delimiter = " "...
bases.py
Source:bases.py
...31 instances = super().make(*args, **kwargs)32 if self._quantity == 1:33 instances = [instances]34 if self._post_create:35 self._post_create(instances, self)36 self.instances.extend(instances)37 return instances[0] if self._quantity == 1 else instances38class RecipeFactory:39 def __init__(self, recipe_templates) -> None:40 self.recipes_templates = recipe_templates41 def make_by_template(self, template: Type[Enum]) -> list[Model]:42 recipe = self.recipes_templates[type(template)][template]43 instances = instances if isinstance(instances := recipe.make(), list) else [instances]44 return {45 "instances": instances,46 "template": recipe.attr_mapping,47 }48 @property49 def instances(self):...
manager.py
Source:manager.py
...5 def _pre_create(self, *args, **kwargs):6 kwargs['designer'] = UserSerializer(kwargs['designed_by']).data7 derivatives = {}8 return args, kwargs, derivatives9 def _post_create(self, instance, **derivatives):10 pass11 def create(self, *args, **kwargs):12 args, kwargs, derivatives = self._pre_create(*args, **kwargs)13 instance = super(PrototypeManager, self).create(*args, **kwargs)14 self._post_create(instance, **derivatives)15 return instance16 def get_or_create(self, *args, **kwargs):17 args, kwargs, derivatives = self._pre_create(*args, **kwargs)18 instance, created = super(PrototypeManager, self).get_or_create(*args, **kwargs)19 self._post_create(instance, **derivatives)...
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!!