How to use _log_calls method in avocado

Best Python code snippet using avocado_python

log.py

Source:log.py Github

copy

Full Screen

1from inspect import getframeinfo, stack2from glearn.utils.printing import colorize3def log(message, color=None, bold=False, highlight=False):4 if color is not None:5 message = colorize(message, color, bold=bold, highlight=highlight)6 print(message)7def log_warning(message, once=False):8 if once and _log_call(message):9 return10 log(message, color="yellow")11def log_error(message, once=False):12 if once and _log_call(message):13 return14 log(message, color="red", bold=True)15class Loggable(object):16 @property17 def debugging(self):18 return False19 def debug(self, message, color=None, bold=False, highlight=False):20 if self.debugging:21 log(message, color=color, bold=bold, highlight=highlight)22 def log(self, message, color=None, bold=False, highlight=False):23 log(message, color=color, bold=bold, highlight=highlight)24 def warning(self, message, once=False):25 if once and _log_call(message):26 return27 log_warning(message)28 def error(self, message, once=False):29 if once and _log_call(message):30 return31 log_error(message)32_log_calls = {}33def _log_call(message):34 # log callstack35 caller = getframeinfo(stack()[2][0])36 key = f"{caller.filename}:{caller.lineno}"37 if _log_calls.get(key, None) == message:38 return True39 _log_calls[key] = message...

Full Screen

Full Screen

mock_cli.py

Source:mock_cli.py Github

copy

Full Screen

1import asyncio2from typing import Optional3from unittest.mock import patch, MagicMock, AsyncMock4class CLIMockingAssistant:5 def __init__(self):6 self._prompt_patch = patch(7 "hummingbot.client.ui.hummingbot_cli.HummingbotCLI.prompt"8 )9 self._prompt_mock: Optional[AsyncMock] = None10 self._prompt_replies = asyncio.Queue()11 self._log_patch = patch(12 "hummingbot.client.ui.hummingbot_cli.HummingbotCLI.log"13 )14 self._log_mock: Optional[MagicMock] = None15 self._log_calls = []16 self.ev_loop = asyncio.get_event_loop()17 def start(self):18 self._prompt_mock = self._prompt_patch.start()19 self._prompt_mock.side_effect = self._get_next_prompt_reply20 self._log_mock = self._log_patch.start()21 self._log_mock.side_effect = self._register_log_call22 def stop(self):23 self._prompt_patch.stop()24 self._log_patch.stop()25 def queue_prompt_reply(self, msg: str):26 self._prompt_replies.put_nowait(msg)27 def check_log_called_with(self, msg: str) -> bool:28 called_with = msg in self._log_calls29 return called_with30 async def _get_next_prompt_reply(self, prompt: str, is_password: bool = False):31 msg = await self._prompt_replies.get()32 return msg33 def _register_log_call(self, text: str, save_log: bool = True):...

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