Best Python code snippet using autotest_python
scenario_base.py
Source: scenario_base.py
...109 left: list of ParserTestResults or a single ParserException110 right: list of ParserTestResults or a single ParserException111 Returns: Generator returned from difflib.Differ().compare()112 """113 def to_los(obj):114 """Generate a list of strings representation of object."""115 if type(obj) is list:116 return [117 '%d) %s' % pair118 for pair in itertools.izip(itertools.count(), obj)]119 else:120 return ['i) %s' % obj]121 return difflib.Differ().compare(to_los(left), to_los(right))122class ParserHarness(object):123 """Harness for objects related to the parser.124 This can exercise a parser on specific result data in various ways.125 """126 def __init__(127 self, parser, job, job_keyval, status_version, status_log_filepath):128 """129 Args:130 parser: tko.parsers.base.parser; Subclass instance of base parser.131 job: job implementation; Returned from parser.make_job()132 job_keyval: dict; Result of parsing job keyval file.133 status_version: str; Status log format version134 status_log_filepath: str; Path to result data status.log file135 """...
sol.py
Source: sol.py
...35MAP = list(map(list, RAW.splitlines()))36def dist2(dc, dr):37 return dc * dc + dr * dr38#Â returns a map from {alpha: (dist2, (r, c)) for all (r, c) in direction alpha wrt (rr, cc)}39def to_los(rr, cc):40 if MAP[rr][cc] == '.': return dict()41 line_of_sight = defaultdict(list)42 for r, row in enumerate(MAP):43 for c, ch in enumerate(row):44 if (r == rr and c == cc) or ch == '.': continue45 delta = (c-cc), (r-rr)46 line_of_sight[atan2(*delta)].append((dist2(*delta), (r, c)))47 return line_of_sight48max_los = dict()49for r in range(len(MAP)):50 for c in range(len(MAP[0])):51 los = to_los(r, c)52 if len(los) > len(max_los):53 max_los = los54print('1)', len(max_los))55alphas = sorted(max_los.keys())[::-1]56n = 057while any(len(max_los[alpha]) for alpha in alphas):58 for alpha in alphas:59 if max_los[alpha]:60 dist, (r, c) = min(max_los[alpha]) # this is the first in line of sight61 max_los[alpha].remove((dist, (r, c)))62 n += 163 if n == 200:64 print('2)', 100 * c + r)65 break
Check out the latest blogs from LambdaTest on this topic:
How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.
Lack of training is something that creates a major roadblock for a tester. Often, testers working in an organization are all of a sudden forced to learn a new framework or an automation tool whenever a new project demands it. You may be overwhelmed on how to learn test automation, where to start from and how to master test automation for web applications, and mobile applications on a new technology so soon.
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
The sky’s the limit (and even beyond that) when you want to run test automation. Technology has developed so much that you can reduce time and stay more productive than you used to 10 years ago. You needn’t put up with the limitations brought to you by Selenium if that’s your go-to automation testing tool. Instead, you can pick from various test automation frameworks and tools to write effective test cases and run them successfully.
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.
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!!