Best Python code snippet using avocado_python
__init__.py
Source: __init__.py
...35 if item not in self.ack_items:36 sub_menu = self.menu.addMenu(' '.join(item.split("/")[4:]))37 action = sub_menu.addAction('Open')38 action.triggered.connect(lambda f=self._open_browser, item=item:39 self._open_browser(item))40 action = sub_menu.addAction('Acknowledge')41 action.triggered.connect(lambda f=self._item_acknowledge,42 menu_items=menu_items,43 item=item:44 self._item_acknowledge(menu_items, item))45 icon = QtGui.QIcon(Resources.ACTIVE_ICON)46 else:47 sub_menu = self.menu.addMenu(f'{" ".join(item.split("/")[4:])} â')48 action = sub_menu.addAction('Open')49 action.triggered.connect(lambda f=self._open_browser, item=item:50 self._open_browser(item))51 if icon != QtGui.QIcon(Resources.ACTIVE_ICON):52 icon = QtGui.QIcon(Resources.ACK_ICON)53 self.menu.addSeparator()54 exit_item = self.menu.addAction('Exit')55 exit_item.triggered.connect(self._shutdown)56 self.setIcon(icon)57 self.setContextMenu(self.menu)58 def _save_ack_items(self) -> None:59 logger.debug('Dumping ack items to disk...')60 Path(BASEDIR.parent / '.ack_items').write_bytes(pickle.dumps(self.ack_items))61 def _load_ack_items(self) -> Set[str]:62 logger.debug('Loading ack items from disk...')63 try:64 return pickle.loads(Path(BASEDIR.parent / '.ack_items').read_bytes())65 except FileNotFoundError:66 return set()67 def _on_activate(self, menu_items: Set['str']) -> None:68 self._update_menu(menu_items=menu_items)69 if menu_items == self.ack_items:70 logger.debug('Changing icon to all ack')71 self.setIcon(QtGui.QIcon(Resources.ACK_ICON))72 else:73 logger.debug('Changing icon to active')74 self.setIcon(QtGui.QIcon(Resources.ACTIVE_ICON))75 def _open_browser(self, url: str) -> None:76 logger.debug(f'Opening {url} using {webbrowser.get().basename}')77 webbrowser.open(url)78 def _item_acknowledge(self, items: Set['str'], item: str) -> None:79 logger.debug(f'Item {item} marked as acknowledge')80 self.ack_items.add(item)81 self._on_activate(items)82 def _shutdown(self) -> None:83 self._save_ack_items()84 logger.info('Shutting down...')...
base.py
Source: base.py
...32 Create a tuple of (browser, setup, tearDown)33 Used to conveniently make file level test fixtures34 """35 instance = cls.from_testconfig()36 setup = lambda: instance._open_browser()37 teardown = lambda: instance._close_browser()38 return instance, setup, teardown39 def _open_browser(self):40 self._browser = Browser()41 def _close_browser(self):42 self._browser.quit()43 def visit(self, url):44 """Custom visit command that takes port, schema and hostname on the runner into account"""45 if '://' not in url and not url.startswith('/'):46 url = "/{}".format(url)47 if url.startswith('/'):48 url = "{}://{}:{}{}".format(self._scheme, self._hostname, self._port, url)49 return self._browser.visit(url)50 def __getattr__(self, key):51 """Proxy everything to the browser object"""52 if key.startswith("_"):53 return object.__getattribute__(self, key)54 browser = self._browser55 if hasattr(browser, key):56 return getattr(browser, key)57 return object.__getattribute__(self, key)58def init():59 """Custom TestCase that starts a browser for every test"""60 @before_each_feature61 def setup(feature):62 """Create our browser"""63 feature.browser = BrowserRunner.from_testconfig()64 feature.browser._open_browser()65 @after_each_feature66 def teardown(feature):67 """Make sure the browser dies"""68 try:69 feature.browser._close_browser()70 except:...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!