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

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Use Playwright For Web Scraping with Python

In today’s data-driven world, the ability to access and analyze large amounts of data can give researchers, businesses & organizations a competitive edge. One of the most important & free sources of this data is the Internet, which can be accessed and mined through web scraping.

Considering Agile Principles from a different angle

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.

How To Automate Mouse Clicks With Selenium Python

Sometimes, in our test code, we need to handle actions that apparently could not be done automatically. For example, some mouse actions such as context click, double click, drag and drop, mouse movements, and some special key down and key up actions. These specific actions could be crucial depending on the project context.

Different Ways To Style CSS Box Shadow Effects

Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.

QA’s and Unit Testing – Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

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