How to use get_markup_vars method in yandex-tank

Best Python code snippet using yandex-tank

screen.py

Source:screen.py Github

copy

Full Screen

...305 result.append(False)306 return all(result)307 left = max_width308 result = ''309 markups = self.markup.get_markup_vars()310 for num, chunk in enumerate(line_arr):311 if chunk in markups:312 result += chunk313 else:314 if left > 0:315 if len(chunk) <= left:316 result += chunk317 left -= len(chunk)318 else:319 leftover = (chunk[left:],) + line_arr[num + 1:]320 was_cut = not is_empty(leftover, markups)321 if was_cut:322 result += chunk[:left - 1] + self.markup.RESET + '…'323 else:324 result += chunk[:left]325 left = 0326 return result327 def __render_left_panel(self):328 ''' Render left blocks '''329 self.log.debug("Rendering left blocks")330 left_block = self.left_panel331 left_block.render()332 blank_space = self.left_panel_width - left_block.width333 lines = []334 pre_space = ' ' * int(blank_space / 2)335 if not left_block.lines:336 lines = [(''), (self.markup.RED + 'BROKEN LEFT PANEL' + self.markup.RESET)]337 else:338 while self.left_panel.lines:339 src_line = self.left_panel.lines.pop(0)340 line = pre_space + self.__truncate(src_line, self.left_panel_width)341 post_space = ' ' * (self.left_panel_width - len(self.markup.clean_markup(line)))342 line += post_space + self.markup.RESET343 lines.append(line)344 return lines345 def render_screen(self):346 ''' Main method to render screen view '''347 self.term_width, self.term_height = get_terminal_size()348 self.log.debug(349 "Terminal size: %sx%s", self.term_width, self.term_height)350 self.right_panel_width = int(351 (self.term_width - len(self.RIGHT_PANEL_SEPARATOR))352 * (float(self.info_panel_percent) / 100)) - 1353 if self.right_panel_width > 0:354 self.left_panel_width = self.term_width - \355 self.right_panel_width - len(self.RIGHT_PANEL_SEPARATOR) - 2356 else:357 self.right_panel_width = 0358 self.left_panel_width = self.term_width - 1359 self.log.debug(360 "Left/right panels width: %s/%s", self.left_panel_width,361 self.right_panel_width)362 widget_output = []363 if self.right_panel_width:364 widget_output = []365 self.log.debug("There are %d info widgets" % len(self.info_widgets))366 for index, widget in sorted(367 self.info_widgets.items(),368 key=lambda item: (item[1].get_index(), item[0])):369 self.log.debug("Rendering info widget #%s: %s", index, widget)370 widget_out = widget.render(self).strip()371 if widget_out:372 widget_output += widget_out.split("\n")373 widget_output += [""]374 left_lines = self.__render_left_panel()375 self.log.debug("Composing final screen output")376 output = []377 for line_no in range(1, self.term_height):378 line = " "379 if line_no > 1 and left_lines:380 left_line = left_lines.pop(0)381 left_line_plain = self.markup.clean_markup(left_line)382 left_line += (383 ' ' * (self.left_panel_width - len(left_line_plain)))384 line += left_line385 else:386 line += ' ' * self.left_panel_width387 if self.right_panel_width:388 line += self.markup.RESET389 line += self.markup.WHITE390 line += self.RIGHT_PANEL_SEPARATOR391 line += self.markup.RESET392 right_line = self.__get_right_line(widget_output)393 line += right_line394 output.append(line)395 return self.markup.new_line.join(output) + self.markup.new_line396 def add_info_widget(self, widget):397 '''398 Add widget string to right panel of the screen399 '''400 index = widget.get_index()401 while index in self.info_widgets:402 index += 1403 self.info_widgets[widget.get_index()] = widget404 def add_second_data(self, data):405 '''406 Notification method about new aggregator data407 '''408 self.left_panel.add_second(data)409class AbstractBlock:410 '''411 Parent class for all left panel blocks412 '''413 def __init__(self, screen):414 self.log = logging.getLogger(__name__)415 self.lines = []416 self.width = 0417 self.screen = screen418 def add_second(self, data):419 '''420 Notification about new aggregate data421 '''422 pass423 def fill_rectangle(self, prepared):424 ''' Right-pad lines of block to equal width '''425 result = []426 width = max([self.clean_len(line) for line in prepared])427 for line in prepared:428 spacer = ' ' * (width - self.clean_len(line))429 result.append(line + (self.screen.markup.RESET, spacer))430 return (width, result)431 def clean_len(self, line):432 ''' Calculate wisible length of string '''433 if isinstance(line, str):434 return len(self.screen.markup.clean_markup(line))435 elif isinstance(line, tuple) or isinstance(line, list):436 markups = self.screen.markup.get_markup_vars()437 length = 0438 for i in line:439 if i not in markups:440 length += len(i)441 return length442 def render(self):443 '''444 Render method, fills .lines and .width properties with rendered data445 '''446 raise RuntimeError("Abstract method needs to be overridden")447class HorizontalBlock(AbstractBlock):448 '''449 Block to merge two other blocks horizontaly450 '''...

Full Screen

Full Screen

plugin.py

Source:plugin.py Github

copy

Full Screen

...127 BG_MAGENTA = '\033[1;45m'128 BG_GREEN = '\033[1;42m'129 BG_BROWN = '\033[1;43m'130 BG_CYAN = '\033[1;46m'131 def get_markup_vars(self):132 return [133 self.YELLOW, self.RED, self.RESET, self.CYAN, self.BG_MAGENTA,134 self.WHITE, self.BG_GREEN, self.GREEN, self.BG_BROWN,135 self.RED_DARK, self.MAGENTA, self.BG_CYAN136 ]137 def clean_markup(self, orig_str):138 ''' clean markup from string '''139 for val in self.get_markup_vars():140 orig_str = orig_str.replace(val, '')141 return orig_str142# ======================================================143# FIXME: 3 better way to have it?144class NoConsoleMarkup(RealConsoleMarkup):145 ''' all colors are disabled '''146 WHITE_ON_BLACK = ''147 TOTAL_RESET = ''148 clear = ""149 new_line = "\n"150 YELLOW = ''151 RED = ''152 RED_DARK = ''153 RESET = ''...

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 yandex-tank 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