How to use _yaml_loads method in pytest-play

Best Python code snippet using pytest-play_python

engine.py

Source:engine.py Github

copy

Full Screen

...68 """ Parametrize data """69 return Parametrizer(70 self.context['variables'],71 context=self.context).parametrize(data)72 def _yaml_loads(self, data):73 """ returns parametrized yaml dumps """74 return yaml.safe_load(75 self.parametrize(data))76 def _merge_payload(self, command):77 """ Merge command with the default command available in78 engine.variables['provider']79 """80 provider = command['provider']81 provider_conf = self.variables.get(provider, {})82 if provider_conf:83 default = self._yaml_loads(84 yaml.dump(provider_conf, default_flow_style=False))85 if provider_conf:86 return self._merge(default, command)87 return command88 def _merge(self, a, b, path=None):89 """ merges b and a configurations.90 Based on http://bit.ly/2uFUHgb91 """92 if path is None:93 path = []94 for key in b:95 if key in a:96 if isinstance(a[key], dict) and isinstance(b[key], dict):97 self._merge(a[key], b[key], path + [str(key)])98 elif a[key] == b[key]:99 pass # same leaf value100 else:101 # b wins102 a[key] = b[key]103 else:104 a[key] = b[key]105 return a106 def skip_condition(func):107 """ Skip command if skip_condition python expression is falsish """108 def wrapper(*args, **kwargs):109 command = args[0]._yaml_loads(110 yaml.dump(args[1], default_flow_style=False))111 condition = command.get('skip_condition', None)112 skip = False113 if condition is not None:114 expr = args[0].parametrize(condition)115 if args[0].execute_command(116 {'provider': 'python',117 'type': 'exec',118 'expression': expr119 }):120 skip = True121 if not skip:122 return func(*args, **kwargs)123 return wrapper124 def execute_raw(self, data, extra_variables={}):125 """ Execute raw yaml-like file contents """126 if extra_variables:127 self.update_variables(extra_variables)128 self.execute(list(yaml.safe_load_all(data))[-1])129 def execute(self, data, extra_variables={}):130 """ Execute parsed yaml-like file contents """131 if extra_variables:132 self.update_variables(extra_variables)133 for step in data:134 self.execute_command(step)135 @skip_condition136 def execute_command(self, command, **kwargs):137 """ Execute single command """138 return_value = None139 command = self._merge_payload(140 self._yaml_loads(141 yaml.dump(142 command, default_flow_style=False))143 )144 command_type = command['type']145 provider_name = command.get('provider', 'default')146 command_provider = self.get_command_provider(provider_name)147 if command_provider is None:148 logger.error('Not supported provider %r', command)149 raise ValueError('Command not supported',150 command_type,151 provider_name)152 method_name = 'command_{0}'.format(command_type)153 method = getattr(command_provider, method_name, None)154 if method is None:...

Full Screen

Full Screen

yaml.py

Source:yaml.py Github

copy

Full Screen

...39 """Yaml loads.40 Include our Loader. Clients do not have to repeat the try...except41 import for CSafeLoader above.42 """43 return _yaml_loads(stream=stream, Loader=Loader or MyLoader)44def yaml_type(45 cls: type,46 tag: str,47 *,48 init: Optional[Callable] = None,49 repr: Optional[Callable] = None, # pylint: disable=redefined-builtin50 loader: Optional[Type[MyLoader]] = None,51 dumper: Optional[Type[MyDumper]] = None,52 **kwargs,53):54 """Yaml type."""55 _loader = loader or MyLoader56 _dumper = dumper or MyDumper57 if init is not None:...

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 pytest-play 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