Best Python code snippet using avocado_python
nrunner.py
Source:nrunner.py
...119 if arg.startswith('-'):120 arg = 'base64:%s' % base64.b64encode(arg.encode()).decode('ascii')121 args.append(arg)122 if self.tags is not None:123 args.append('tags=json:%s' % json.dumps(self.get_serializable_tags()))124 for key, val in self.kwargs.items():125 if not isinstance(val, str) or isinstance(val, int):126 val = "json:%s" % json.dumps(val)127 args.append('%s=%s' % (key, val))128 return args129 def get_dict(self):130 """131 Returns a dictionary representation for the current runnable132 This is usually the format that will be converted to a format133 that can be serialized to disk, such as JSON.134 :rtype: :class:`collections.OrderedDict`135 """136 recipe = collections.OrderedDict(kind=self.kind)137 if self.uri is not None:138 recipe['uri'] = self.uri139 recipe['config'] = self.config140 if self.args is not None:141 recipe['args'] = self.args142 kwargs = self.kwargs.copy()143 if self.tags is not None:144 kwargs['tags'] = self.get_serializable_tags()145 if kwargs:146 recipe['kwargs'] = kwargs147 return recipe148 def get_json(self):149 """150 Returns a JSON representation151 :rtype: str152 """153 return json.dumps(self.get_dict())154 def get_serializable_tags(self):155 tags = {}156 # sets are not serializable in json157 for key, val in self.tags.items():158 if isinstance(val, set):159 val = list(val)160 tags[key] = val161 return tags162 def write_json(self, recipe_path):163 """164 Writes a file with a JSON representation (also known as a recipe)165 """166 with open(recipe_path, 'w') as recipe_file:167 recipe_file.write(self.get_json())168 def is_kind_supported_by_runner_command(self, runner_command):...
runnable.py
Source:runnable.py
...232 if arg.startswith("-"):233 arg = f"base64:{base64.b64encode(arg.encode()).decode('ascii')}"234 args.append(arg)235 if self.tags is not None:236 args.append(f"tags=json:{json.dumps(self.get_serializable_tags())}")237 if self.variant is not None:238 args.append(f"variant=json:{json.dumps(self.variant)}")239 if self.output_dir is not None:240 args.append(f"output_dir={self.output_dir}")241 for key, val in self.kwargs.items():242 if not isinstance(val, str) or isinstance(val, int):243 val = f"json:{json.dumps(val)}"244 args.append(f"{key}={val}")245 return args246 def get_dict(self):247 """248 Returns a dictionary representation for the current runnable249 This is usually the format that will be converted to a format250 that can be serialized to disk, such as JSON.251 :rtype: :class:`collections.OrderedDict`252 """253 recipe = collections.OrderedDict(kind=self.kind)254 if self.uri is not None:255 recipe["uri"] = self.uri256 recipe["config"] = self.config257 if self.args is not None:258 recipe["args"] = self.args259 kwargs = self.kwargs.copy()260 if self.tags is not None:261 kwargs["tags"] = self.get_serializable_tags()262 if self.variant is not None:263 kwargs["variant"] = self.variant264 if self.output_dir is not None:265 kwargs["output_dir"] = self.output_dir266 if kwargs:267 recipe["kwargs"] = kwargs268 return recipe269 def get_json(self):270 """271 Returns a JSON representation272 :rtype: str273 """274 return json.dumps(self.get_dict(), cls=ConfigEncoder)275 def get_serializable_tags(self):276 if self.tags is None:277 return {}278 tags = {}279 # sets are not serializable in json280 for key, val in self.tags.items():281 if isinstance(val, set):282 val = list(val)283 tags[key] = val284 return tags285 def write_json(self, recipe_path):286 """287 Writes a file with a JSON representation (also known as a recipe)288 """289 with open(recipe_path, "w", encoding="utf-8") as recipe_file:...
messages.py
Source:messages.py
...151 message["time_end"] = time_end152 message["actual_time_end"] = time.time()153 message["time_elapsed"] = time_elapsed154 message["logdir"] = task.metadata["task_path"]155 message["tags"] = task.runnable.get_serializable_tags()156 if task.category == "test":157 job.result.check_test(message)158 job.result_events_dispatcher.map_method("end_test", job.result, message)159class BaseRunningMessageHandler(BaseMessageHandler):160 """Base interface for resolving running messages."""161 _tag = b""162 def __init__(self):163 self.line_buffer = b""164 def _split_complete_lines(self, data):165 """166 It will split data into list of lines.167 If the data don't finish with the new line character, the last line is168 marked as incomplete, and it is saved to the line buffer for next usage.169 When the buffer is not empty the buffer will be added at the beginning...
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!!