How to use reject_nones method in Gherkin-python

Best Python code snippet using gherkin-python

views.py

Source: views.py Github

copy

Full Screen

...820 col_idx = headers.index(col_name)821 except ValueError:822 return None823 return {'col_idx': col_idx, 'desc': sort.get('desc', False)}824 def reject_nones(xs):825 return [x for x in xs if x is not None]826 return reject_nones(parse_sorting(s) for s in sorting)827def dev_only_ckan_check_permissions(request):828 if settings.PRODUCTION:829 raise Http404('View does not exist in production')830 # Uncomment to simulate user not logged in to CKAN831 # from django.http import HttpResponseForbidden832 # return HttpResponseForbidden()833 # organisations = [834 # 'anu-abc-upload', 'bpa-sepsis', 'australian-microbiome', 'bpa-project-documentation', 'bpa-barcode',835 # 'bioplatforms-australia', 'bpa-base', 'bpa-great-barrier-reef', 'incoming-data', 'bpa-marine-microbes',836 # 'bpa-melanoma', 'bpa-omg', 'bpa-stemcells', 'bpa-wheat-cultivars', 'bpa-wheat-pathogens-genomes',837 # 'bpa-wheat-pathogens-transcript']838 organisations = ['australian-microbiome']839 data = json.dumps({840 'email': settings.CKAN_DEVELOPMENT_USER_EMAIL,...

Full Screen

Full Screen

ast_builder.py

Source: ast_builder.py Github

copy

Full Screen

...67 if node.get_single('DataTable'):68 step_argument = node.get_single('DataTable')69 elif node.get_single('DocString'):70 step_argument = node.get_single('DocString')71 return self.reject_nones({72 'type': node.rule_type,73 'location': self.get_location(step_line),74 'keyword': step_line.matched_keyword,75 'text': step_line.matched_text,76 'argument': step_argument77 })78 elif node.rule_type == 'DocString':79 separator_token = node.get_tokens('DocStringSeparator')[0]80 content_type = (separator_token.matched_text if len(separator_token.matched_text) > 081 else None)82 line_tokens = node.get_tokens('Other')83 content = '\n'.join([t.matched_text for t in line_tokens])84 return self.reject_nones({85 'type': node.rule_type,86 'location': self.get_location(separator_token),87 'contentType': content_type,88 'content': content89 })90 elif node.rule_type == 'DataTable':91 rows = self.get_table_rows(node)92 return self.reject_nones({93 'type': node.rule_type,94 'location': rows[0]['location'],95 'rows': rows,96 })97 elif node.rule_type == 'Background':98 background_line = node.get_token('BackgroundLine')99 description = self.get_description(node)100 steps = self.get_steps(node)101 return self.reject_nones({102 'type': node.rule_type,103 'location': self.get_location(background_line),104 'keyword': background_line.matched_keyword,105 'name': background_line.matched_text,106 'description': description,107 'steps': steps108 })109 elif node.rule_type == 'Scenario_Definition':110 tags = self.get_tags(node)111 scenario_node = node.get_single('Scenario')112 if scenario_node:113 scenario_line = scenario_node.get_token('ScenarioLine')114 description = self.get_description(scenario_node)115 steps = self.get_steps(scenario_node)116 return self.reject_nones({117 'type': scenario_node.rule_type,118 'tags': tags,119 'location': self.get_location(scenario_line),120 'keyword': scenario_line.matched_keyword,121 'name': scenario_line.matched_text,122 'description': description,123 'steps': steps124 })125 else:126 scenario_outline_node = node.get_single('ScenarioOutline')127 if not scenario_outline_node:128 raise RuntimeError('Internal grammar error')129 scenario_outline_line = scenario_outline_node.get_token('ScenarioOutlineLine')130 description = self.get_description(scenario_outline_node)131 steps = self.get_steps(scenario_outline_node)132 examples = scenario_outline_node.get_items('Examples_Definition')133 return self.reject_nones({134 'type': scenario_outline_node.rule_type,135 'tags': tags,136 'location': self.get_location(scenario_outline_line),137 'keyword': scenario_outline_line.matched_keyword,138 'name': scenario_outline_line.matched_text,139 'description': description,140 'steps': steps,141 'examples': examples142 })143 elif node.rule_type == 'Examples_Definition':144 tags = self.get_tags(node)145 examples_node = node.get_single('Examples')146 examples_line = examples_node.get_token('ExamplesLine')147 description = self.get_description(examples_node)148 examples_table = examples_node.get_single('Examples_Table')149 return self.reject_nones({150 'type': examples_node.rule_type,151 'tags': tags,152 'location': self.get_location(examples_line),153 'keyword': examples_line.matched_keyword,154 'name': examples_line.matched_text,155 'description': description,156 'tableHeader': examples_table['tableHeader'] if examples_table else None,157 'tableBody': examples_table['tableBody'] if examples_table else None158 })159 elif node.rule_type == 'Examples_Table':160 rows = self.get_table_rows(node)161 return self.reject_nones({162 'tableHeader': rows[0],163 'tableBody': rows[1:]164 })165 elif node.rule_type == 'Description':166 line_tokens = node.get_tokens('Other')167 # Trim trailing empty lines168 last_non_empty = next(i for i, j in reversed(list(enumerate(line_tokens)))169 if j.matched_text)170 description = '\n'.join([token.matched_text for token in171 line_tokens[:last_non_empty + 1]])172 return description173 elif node.rule_type == 'Feature':174 header = node.get_single('Feature_Header')175 if not header:176 return177 tags = self.get_tags(header)178 feature_line = header.get_token('FeatureLine')179 if not feature_line:180 return181 children = []182 background = node.get_single('Background')183 if (background):184 children.append(background)185 children = children + node.get_items('Scenario_Definition')186 description = self.get_description(header)187 language = feature_line.matched_gherkin_dialect188 return self.reject_nones({189 'type': node.rule_type,190 'tags': tags,191 'location': self.get_location(feature_line),192 'language': language,193 'keyword': feature_line.matched_keyword,194 'name': feature_line.matched_text,195 'description': description,196 'children': children197 })198 elif node.rule_type == 'GherkinDocument':199 feature = node.get_single('Feature')200 return self.reject_nones({201 'type': node.rule_type,202 'feature': feature,203 'comments': self.comments204 })205 else:206 return node207 def reject_nones(self, values):...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Why Agile Is Great for Your Business

Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.

Guide To Find Index Of Element In List with Python Selenium

In an ideal world, you can test your web application in the same test environment and return the same results every time. The reality can be difficult sometimes when you have flaky tests, which may be due to the complexity of the web elements you are trying to perform an action on your test case.

A Complete Guide To CSS Grid

Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Find Hidden Elements In Selenium WebDriver With Java

Have you ever struggled with handling hidden elements while automating a web or mobile application? I was recently automating an eCommerce application. I struggled with handling hidden elements on the web page.

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 Gherkin-python 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