Best Python code snippet using grail_python
step_info.py
Source:step_info.py
...23 function = None24 args = None25 kwargs = None26 elapsed_time = 027 def _get_clean_params(self):28 args = self.args29 if args:30 args_def = inspect.getargspec(self.function)[0]31 if args_def and args_def[0] == 'self':32 args = args[1:]33 return args, self.kwargs34 def _get_name_based_description(self):35 return ' '.join(self.function.func_name.split('_'))36 def _get_arguments_string(self):37 args, kwargs = self._get_clean_params()38 if settings.export_mode:39 args = [arg for arg in args if arg]40 kwargs = {k: v for k, v in kwargs.items() if v}41 if len(args) == 0 and len(kwargs) == 0:42 return ''43 args = map(unicode_replace, args)44 kw_arguments = ['{0}={1}'.format(k, v) for k, v in kwargs.items()]45 return ' (' + ', '.join(args + kw_arguments) + ')'46 def run_function(self):47 start = time.time()48 result = self.function(*self.args, **self.kwargs)49 self.elapsed_time = time.time() - start50 return result51 def get_description(self, output, result, exception_instance):52 message = ''53 if settings.export_mode:54 if result == StepResults.FAILED:55 raise RuntimeError('Unexpected failure during export')56 else:57 if settings.print_step_time:58 message += settings.step_time_template.format(self.elapsed_time)59 message += result + ' '60 if self.format_description:61 args, kwargs = self._get_clean_params()62 message += self.description.format(*args, **kwargs)63 else:64 message += self.description or self._get_name_based_description()65 if self.log_input:66 message += self._get_arguments_string()67 if self.log_output and output:68 message += ' -> ' + unicode_replace(output)69 if exception_instance:70 message += ': %s' % unicode_replace(exception_instance)...
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!!