Best Python code snippet using autotest_python
watchdog_tester.py
Source: watchdog_tester.py
...44 self._client.hostname, self._hw_interval)45 # machine should became unpingable after lockup46 # ...give 5 seconds slack...47 wait_down = self._hw_interval + 548 if not self._client.wait_down(timeout=wait_down):49 raise error.TestError('machine should be unpingable '50 'within %d seconds' % wait_down)51 # make sure the machine comes back,52 # DHCP can take up to 45 seconds in odd cases.53 if not self._client.wait_up(timeout=timeout):54 raise error.TestError('machine did not reboot/ping within '55 '%d seconds of HW reset' % timeout)56 def __exit__(self, exception, value, traceback):...
db.py
Source: db.py
1from dataclasses import dataclass2from random import choices, randint3from string import ascii_letters, digits4from typing import Optional5from uuid import UUID, uuid46def randword():7 return "".join(choices(ascii_letters, k=randint(12, 18)))8@dataclass9class Route:10 id: UUID11 number: str12 stops: list["Stop"]13 def __lt__(self, other):14 return len(self.number) < len(other.number) or self.number < other.number15@dataclass16class Stop:17 id: UUID18 name: str19 wait_down: int = 020 wait_up: int = 021 bus_down: Optional[str] = None22 bus_up: Optional[str] = None23 @property24 def time(self):25 bus_down = self.bus_down or "âââ"26 bus_up = self.bus_up or "âââ"27 return (28 f"{bus_down} â {self.wait_down: >2} | {self.wait_up: >2} â {bus_up}"29 )30routes: list[Route] = []31for i in range(60):32 number = str(randint(1, 99))33 if i == 0:34 number = str(41)35 if any(map(lambda route: route.number == number, routes)):36 continue37 stops: list[Stop] = []38 for _ in range(randint(20, 30)):39 prev_down = stops[-1].wait_down if stops else 040 prev_up = stops[-1].wait_up if stops else 041 if delta_up := randint(0, 6):42 up = prev_up + delta_up43 bus_up = None44 else:45 up = 046 bus_up = "".join(choices(digits, k=3))47 if (delta_down := randint(1, 6)) > prev_down:48 down = randint(15, 60)49 if stops:50 stops[-1].bus_down = "".join(choices(digits, k=3))51 else:52 down = prev_down - delta_down53 stop = Stop(uuid4(), randword(), down, up, bus_up=bus_up)54 stops.append(stop)55 routes.append(Route(uuid4(), number=number, stops=stops))56routes.sort()57def get_route(id: str) -> Route:58 for route in routes:59 if str(route.id) == id:60 return route...
RedWhiteBlueSnoring.py
Source: RedWhiteBlueSnoring.py
1# Carl Ferkinhoff2# starting from from adafruit example3# https://learn.adafruit.com/welcome-to-circuitpython/creating-and-editing-code4#5import time6from adafruit_circuitplayground import cp7# set up the (red) LED8#cp.pixels.brightness = 0.19#cp.pixels.fill((50,50,50))10 11while True:12 length = 15 #sets the length of the snore13 j=014 wait_down = .0115 wait_up = .0116 while (j<length):17 cp.pixels[0]=(150-j, 0, 0)18 cp.pixels[9]=(150-j, 0, 0)19 cp.pixels[1]=(0, 0,15-j)20 cp.pixels[8]=(0, 0,15-j)21 cp.pixels[2]=(15-j,15-j,15-j)22 cp.pixels[7]=(15-j,15-j,15-j)23 cp.pixels[3]=(0, 0,15-j)24 cp.pixels[6]=(0, 0,15-j)25 cp.pixels[4]=(150-j, 0, 0)26 cp.pixels[5]=(150-j, 0, 0)27 j = j+128 time.sleep(wait_down)29 time.sleep(.01)30 while (j>0):31 cp.pixels[0]=(50-j, 0, 0)32 cp.pixels[9]=(50-j, 0, 0)33 cp.pixels[1]=(0, 0,255-j)34 cp.pixels[8]=(0, 0,255-j)35 cp.pixels[2]=(15-j,15-j,15-j)36 cp.pixels[7]=(15-j,15-j,15-j)37 cp.pixels[3]=(0, 0,255-j)38 cp.pixels[6]=(0, 0,255-j)39 cp.pixels[4]=(50-j, 0, 0)40 cp.pixels[5]=(50-j, 0, 0)41 j = j-1...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!