How to use _prepare_message method in avocado

Best Python code snippet using avocado_python

utilNotify.py

Source:utilNotify.py Github

copy

Full Screen

...11class YesNoPopup(ConfirmCancelPopup):12 OK_BUTTON_TEXT = "Yes"13 CANCEL_BUTTON_TEXT = "No"14 15def _prepare_message(message):16 if isinstance(message, list) or isinstance(message, tuple):17 return "\n".join([ s.rstrip() for s in message])18 #return "\n".join(message)19 else:20 return message21def _wrap_message_lines(message, line_length):22 lines = []23 for line in message.split('\n'):24 lines.extend(textwrap.wrap(line.rstrip(), line_length))25 return lines26 27def notify(message, title="Message", form_color='STANDOUT', 28 wrap=True, wide=False,29 ):30 message = _prepare_message(message)31 if wide:32 F = fmPopup.PopupWide(name=title, color=form_color)33 else:34 F = fmPopup.Popup(name=title, color=form_color)35 F.preserve_selected_widget = True36 mlw = F.add(wgmultiline.Pager,)37 mlw_width = mlw.width-138 if wrap:39 message = _wrap_message_lines(message, mlw_width)40 mlw.values = message41 F.display()42 43def notify_confirm(message, title="Message", form_color='STANDOUT', wrap=True, wide=False,44 editw = 0,):45 message = _prepare_message(message)46 if wide:47 F = fmPopup.PopupWide(name=title, color=form_color)48 else:49 F = fmPopup.Popup(name=title, color=form_color)50 F.preserve_selected_widget = True51 mlw = F.add(wgmultiline.Pager,)52 mlw_width = mlw.width-153 if wrap:54 message = _wrap_message_lines(message, mlw_width)55 else:56 message = message.split("\n")57 mlw.values = message58 F.editw = editw59 F.edit()60def notify_wait(*args, **keywords):61 notify(*args, **keywords)62 curses.napms(3000)63 curses.flushinp() 64 65 66def notify_ok_cancel(message, title="Message", form_color='STANDOUT', wrap=True, editw = 0,):67 message = _prepare_message(message)68 F = ConfirmCancelPopup(name=title, color=form_color)69 F.preserve_selected_widget = True70 mlw = F.add(wgmultiline.Pager,)71 mlw_width = mlw.width-172 if wrap:73 message = _wrap_message_lines(message, mlw_width)74 mlw.values = message75 F.editw = editw76 F.edit()77 return F.value78def notify_yes_no(message, title="Message", form_color='STANDOUT', wrap=True, editw = 0,):79 message = _prepare_message(message)80 F = YesNoPopup(name=title, color=form_color)81 F.preserve_selected_widget = True82 mlw = F.add(wgmultiline.Pager,)83 mlw_width = mlw.width-184 if wrap:85 message = _wrap_message_lines(message, mlw_width)86 mlw.values = message87 F.editw = editw88 F.edit()89 return F.value...

Full Screen

Full Screen

log.py

Source:log.py Github

copy

Full Screen

...7 self.printed = 08 self.prepend = ""9 def reset(self):10 self.printed = 011 def _prepare_message(self, msg):12 return self.prepend + msg13 def title(self, msg):14 self.printed += 115 cprint(self._prepare_message(msg), attrs=["underline", "bold"])16 def bold(self, msg):17 self.printed += 118 cprint(self._prepare_message(msg), attrs=["bold"])19 def debug(self, msg):20 if self.level:21 self.printed += 122 cprint(self._prepare_message(msg), "cyan")23 def warn(self, msg):24 self.printed += 125 cprint(self._prepare_message(msg), "yellow")26 def info(self, msg):27 self.printed += 128 cprint(self._prepare_message(msg), "green")29 def text(self, msg):30 sys.stdout.write(self._prepare_message(msg))31 def error(self, msg):32 self.printed += 133 cprint(self._prepare_message(msg), "red")34 def remove_last_line(self):35 if self.level <= 0:36 self.printed -= 137 CURSOR_UP_ONE = '\x1b[1A'38 ERASE_LINE = '\x1b[2K'39 print(CURSOR_UP_ONE + ERASE_LINE + CURSOR_UP_ONE)40 def clear(self, number=-1):41 if self.level <= 0:42 if number < 0:43 number = self.printed44 for i in range(number):45 self.remove_last_line()46 self.printed = 047import termcolor...

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 avocado 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