How to use _extract_const method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...153 # Add subsystem:default if subsystem is not specified.154 self._set_set('attributes', val)155 if not any(a.startswith('subsystem') for a in self.attributes):156 self.attributes.add('subsystem:default')157def _extract_const(expr):158 assert(expr.__class__ == compiler.ast.Const)159 assert(expr.value.__class__ in (str, int, float, unicode))160 return str(expr.value).strip()161def _extract_dict(expr):162 assert(expr.__class__ == compiler.ast.Dict)163 assert(expr.items.__class__ == list)164 cf_dict = {}165 for key, value in expr.items:166 try:167 key = _extract_const(key)168 val = _extract_expression(value)169 except (AssertionError, ValueError):170 pass171 else:172 cf_dict[key] = val173 return cf_dict174def _extract_list(expr):175 assert(expr.__class__ == compiler.ast.List)176 list_values = []177 for value in expr.nodes:178 try:179 list_values.append(_extract_expression(value))180 except (AssertionError, ValueError):181 pass182 return list_values183def _extract_name(expr):184 assert(expr.__class__ == compiler.ast.Name)185 assert( in ('False', 'True', 'None'))186 return str( _extract_expression(expr):188 if expr.__class__ == compiler.ast.Const:189 return _extract_const(expr)190 if expr.__class__ == compiler.ast.Name:191 return _extract_name(expr)192 if expr.__class__ == compiler.ast.Dict:193 return _extract_dict(expr)194 if expr.__class__ == compiler.ast.List:195 return _extract_list(expr)196 raise ValueError('Unknown rval %s' % expr)197def _extract_assignment(n):198 assert(n.__class__ == compiler.ast.Assign)199 assert(n.nodes.__class__ == list)200 assert(len(n.nodes) == 1)201 assert(n.nodes[0].__class__ == compiler.ast.AssName)202 assert(n.nodes[0].flags.__class__ == str)203 assert(n.nodes[0].name.__class__ == str)...

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:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest 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?