How to use make_indentation method in Behave

Best Python code snippet using behave

pretty2.py

Source:pretty2.py Github

copy

Full Screen

...39 def reset_statement(self):40 self.location_indentations = []41 self.step_lines = 042 def build_indentations(self, levels):43 return [ make_indentation(level * self.indent_size)44 for level in levels]45 def location_text(self, text, indent_size=0):46 if not text:47 return u''48 indentation = make_indentation(indent_size)49 return u'%s # %s' % (indentation, text)50 def calculate_terminal_lines(self, text):51 lines = text.splitlines()52 lines_count = len(lines)53 wrapped_lines = 054 use_wrapped_lines = True55 if use_wrapped_lines:56 for line in lines:57 if len(line) >= self.terminal_width:58 wrapped_lines += 159 # XXX import sys60 # XXX sys.__stdout__.write("XXX wrapped lines: %s (terminal_width=%s)\n" % (wrapped_lines, self.terminal_width))61 return lines_count + wrapped_lines62 def calculate_location_indentations(self, statement, steps):63 line_widths = []64 for s in [statement] + steps:65 text = s.keyword + ' ' + s.name66 line_widths.append(len(text))67 max_line_width = max(line_widths)68 self.location_indentations = [max_line_width - width69 for width in line_widths]70 def print_feature_head(self, feature):71 #self.print_comments(feature.comments, '')72 indentation = self.indentations[self.INDENT_FEATURE]73 self.print_tags(feature.tags, indentation)74 text = u"%s%s: %s" % (indentation, feature.keyword, feature.name)75 self.writer.write(text, style="feature")76 if self.show_source:77 text = self.location_text(six.text_type(feature.location), 2)78 self.writer.write(text, style="comments")79 self.writer.write("\n")80 indentation = self.indentations[self.INDENT_FEATURE_DESCRIPTION]81 self.print_description(feature.description, indentation, True)82 self.writer.flush()83 def print_statement_head(self, statement, steps=None):84 self.writer.write(u"\n")85 #self.print_comments(self.statement.comments, ' ')86 indentation = self.indentations[self.INDENT_SCENARIO]87 if hasattr(statement, 'tags'):88 self.print_tags(statement.tags, indentation)89 text = u"%s%s: %s " % (indentation, statement.keyword,90 statement.name)91 self.writer.write(text, style="scenario")92 if self.show_location:93 steps = steps or []94 self.calculate_location_indentations(statement, steps)95 if self.show_source:96 assert self.show_location97 indent_size = self.location_indentations.pop(0)98 location = six.text_type(statement.location)99 text = self.location_text(location, indent_size)100 self.writer.write(text, style="comments")101 self.writer.write("\n")102 description = getattr(statement, "description", None)103 if self.show_scenario_description and description:104 indentation = make_indentation(self.indent_size*2)105 self.print_description(description, indentation)106 def print_examples(self, examples):107 indentation = self.indentations[self.INDENT_SCENARIO]108 self.writer.write("\n")109 self.print_comments(examples.comments, indentation)110 self.print_tags(examples.tags, indentation)111 self.writer.write('%s%s: %s\n' % (indentation,112 examples.keyword, examples.name))113 indentation = self.indentations[self.INDENT_SCENARIO_DESCRIPTION]114 self.print_description(examples.description, indentation)115 self.print_table(examples.rows)116 self.writer.flush()117 def print_step_with_proceed(self, step, status, match, proceed=True):118 location_indentsize = 0...

Full Screen

Full Screen

plain.py

Source:plain.py Github

copy

Full Screen

...34 if self._multiline_indentation is None:35 offset = 036 if self.show_aligned_keywords:37 offset = 238 indentation = make_indentation(3 * self.indent_size + offset)39 self._multiline_indentation = indentation40 return self._multiline_indentation41 def reset_steps(self):42 self.steps = []43 # -- IMPLEMENT-INTERFACE FOR: Formatter44 def feature(self, feature):45 self.reset_steps()46 self.stream.write(u'%s: %s\n' % (feature.keyword, feature.name))47 def background(self, background):48 self.reset_steps()49 indent = make_indentation(self.indent_size)50 text = u'%s%s: %s\n' % (indent, background.keyword, background.name)51 self.stream.write(text)52 def scenario(self, scenario):53 self.reset_steps()54 self.stream.write(u'\n')55 indent = make_indentation(self.indent_size)56 text = u'%s%s: %s\n' % (indent, scenario.keyword, scenario.name)57 self.stream.write(text)58 def scenario_outline(self, outline):59 self.reset_steps()60 indent = make_indentation(self.indent_size)61 text = u'%s%s: %s\n' % (indent, outline.keyword, outline.name)62 self.stream.write(text)63 def step(self, step):64 self.steps.append(step)65 def result(self, result):66 """67 Process the result of a step (after step execution).68 :param result:69 """70 step = self.steps.pop(0)71 indent = make_indentation(2 * self.indent_size)72 if self.show_aligned_keywords:73 # -- RIGHT-ALIGN KEYWORDS (max. keyword width: 6):74 text = u'%s%6s %s ... ' % (indent, step.keyword, step.name)75 else:76 text = u'%s%s %s ... ' % (indent, step.keyword, step.name)77 self.stream.write(text)78 status = result.status79 if self.show_timings:80 status += " in %0.3fs" % step.duration81 if result.error_message:82 self.stream.write(u'%s\n%s\n' % (status, result.error_message))83 else:84 self.stream.write(u'%s\n' % status)85 if self.show_multiline:...

Full Screen

Full Screen

travis.py

Source:travis.py Github

copy

Full Screen

...31 Process the result of a step (after step execution).32 :param step: Step object with result to process.33 """34 step = self.steps.pop(0)35 indent = make_indentation(2 * self.indent_size)36 if self.show_aligned_keywords:37 # -- RIGHT-ALIGN KEYWORDS (max. keyword width: 6):38 text = u"%s%6s %s" % (indent, step.keyword, step.name)39 else:40 text = u"%s%s %s" % (indent, step.keyword, step.name)41 text = escapes[step.status.name] + textwrap.shorten(text, width=self.LINE_WIDTH - 30) + escapes['reset'] + ' '42 self.stream.write(text)43 status_text = ': '44 if step.status.name == 'passed':45 status_text += u'\u2713'46 else:47 status_text += u'\u26A0'48 if self.show_timings:49 status_text += " in %0.3fs" % step.duration...

Full Screen

Full Screen

util_communication.py

Source:util_communication.py Github

copy

Full Screen

...19 break20# A function used to communicate with the user, which asks to21# choose one of several available options (by entering its number).22def ask_user_for_an_option_choice(question, val_rec_prompt, items, single_choice=True, indentation_level=1):23 def make_indentation(text, indentation_level):24 if indentation_level<0: indentation_level=025 indented_text = ''26 for i in range(indentation_level):27 indented_text = '\t' + indented_text28 indented_text = indented_text+text29 return indented_text30 31 print(make_indentation(question, indentation_level-1))32 allowed_numbers = []33 for it_num, item in enumerate(items):34 print(make_indentation('(%i)'%(it_num+1)+str(item), indentation_level))35 allowed_numbers.append(str(it_num+1))36 while True:37 user_input = input(make_indentation(val_rec_prompt, indentation_level))38 # We allow either single responses or multiple responses39 if single_choice:40 if user_input in allowed_numbers:41 return items[int(user_input)-1]42 else:43 split_input = user_input.split(' ')44 if len(split_input) == 1:45 if user_input in allowed_numbers:46 return [items[int(user_input)-1]]47 else:48 output_options = []49 for sub_input in split_input:50 if sub_input in allowed_numbers:51 output_options.append(items[int(sub_input)-1])...

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:

YouTube

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

Run Behave 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