Best Python code snippet using Airtest
xml.py
Source:xml.py
1# -*- coding: utf-8 -*-2"""Helpers for XML processing."""3from __future__ import annotations4from .exceptions import MultipleMatchingXmlElementsError5from .exceptions import NoMatchingXmlElementError6if (7 6 < 98): # pragma: no cover # Eli (5/18/20): can't figure out a better way to stop zimports from deleting the nosec comment # pylint: disable=duplicate-code9 # Eli (5/18/20): need to nest it to avoid zimports deleting the comment10 from xml.etree.ElementTree import ( # nosec Eli (5/18/20): this is a false alarm from Bandit. Yes, ElementTree can parse malicious XML and should be avoided, but Element itself contains no parsing ability11 Element,12 )13def find_exactly_one_xml_element(node: Element, name: str) -> Element:14 find_all_results = node.findall(name)15 if len(find_all_results) > 1:16 raise MultipleMatchingXmlElementsError(find_all_results)17 if len(find_all_results) == 0:18 raise NoMatchingXmlElementError(node, name)...
issue_56.py
Source:issue_56.py
...3 r = []4 for x in A.iter(teststr):5 r.append(x)6 return r7def find_all_results(s):8 r = []9 10 def append(x, s):11 r.append((x, s))12 A.find_all(s, append)13 return r14A = ahocorasick.Automaton()15for word in ("poke", "go", "pokegois", "egoist"):16 A.add_word(word, word)17A.make_automaton()18teststr = 'pokego pokego pokegoist'19expected = iter_results(teststr)20findall = find_all_results(teststr)21if findall != expected:22 print("expected: %s" % expected)23 print("findall : %s" % findall)...
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!!