Best Python code snippet using gherkin-python
compiler.py
Source:compiler.py
...50 def _compile_scenario(self, uri, inherited_tags, background_steps, scenario, language, pickles):51 tags = list(inherited_tags) + list(scenario['tags'])52 steps = list()53 if scenario['steps']:54 steps.extend(self._pickle_steps(background_steps + scenario['steps']))55 pickle = {56 'astNodeIds': [scenario['id']],57 'id': self.id_generator.get_next_id(),58 'tags': self._pickle_tags(tags),59 'name': scenario['name'],60 'language': language,61 'steps': steps,62 'uri': uri63 }64 pickles.append(pickle)65 def _compile_scenario_outline(self, uri, inherited_tags, background_steps, scenario, language, pickles):66 for examples in (e for e in scenario['examples'] if 'tableHeader' in e):67 variable_cells = examples['tableHeader']['cells']68 for values in examples['tableBody']:69 value_cells = values['cells']70 steps = list()71 if scenario['steps']:72 steps.extend(self._pickle_steps(background_steps))73 tags = list(inherited_tags) + list(scenario['tags']) + list(examples['tags'])74 if scenario['steps']:75 for outline_step in scenario['steps']:76 step_text = self._interpolate(77 outline_step['text'],78 variable_cells,79 value_cells)80 argument = self._create_pickle_arguments(81 outline_step,82 variable_cells,83 value_cells)84 _pickle_step = {85 'astNodeIds': [outline_step['id'], values['id']],86 'id': self.id_generator.get_next_id(),87 'text': step_text88 }89 if argument is not None:90 _pickle_step['argument'] = argument91 steps.append(_pickle_step)92 pickle = {93 'astNodeIds': [scenario['id'], values['id']],94 'id': self.id_generator.get_next_id(),95 'name': self._interpolate(96 scenario['name'],97 variable_cells,98 value_cells),99 'language': language,100 'steps': steps,101 'tags': self._pickle_tags(tags),102 'uri': uri103 }104 pickles.append(pickle)105 def _create_pickle_arguments(self, step, variables, values):106 if 'dataTable' in step:107 table = {'rows': []}108 for row in step['dataTable']['rows']:109 cells = [110 {111 'value': self._interpolate(cell['value'], variables, values)112 } for cell in row['cells']113 ]114 table['rows'].append({'cells': cells})115 return {'dataTable': table}116 elif 'docString' in step:117 argument = step['docString']118 docstring = {119 'content': self._interpolate(argument['content'], variables, values)120 }121 if 'mediaType' in argument:122 docstring['mediaType'] = self._interpolate(argument['mediaType'], variables, values)123 return {'docString': docstring}124 else:125 return None126 def _interpolate(self, name, variable_cells, value_cells):127 if name is None:128 return name129 for n, variable_cell in enumerate(variable_cells):130 value_cell = value_cells[n]131 name = re.sub(132 u'<{0[value]}>'.format(variable_cell),133 value_cell['value'],134 name135 )136 return name137 def _pickle_steps(self, steps):138 return [self._pickle_step(step)for step in steps]139 def _pickle_step(self, step):140 pickle_step = {141 'astNodeIds': [step['id']],142 'id': self.id_generator.get_next_id(),143 'text': step['text'],144 }145 argument = self._create_pickle_arguments(146 step,147 [],148 [])149 if argument is not None:150 pickle_step['argument'] = argument151 return pickle_step...
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!!