How to use is_down method in autotest

Best Python code snippet using autotest_python

ring-bahn.py

Source:ring-bahn.py Github

copy

Full Screen

1print("RRRRRR IIIII NN NN GGGG BBBBB AAA HH HH NN NN ")2print("RR RR III NNN NN GG GG BB B AAAAA HH HH NNN NN")3print("RRRRRR III NN N NN GG _____ BBBBBB AA AA HHHHHHH NN N NN")4print("RR RR III NN NNN GG GG BB BB AAAAAAA HH HH NN NNN ")5print("RR RR IIIII NN NN GGGGGG BBBBBB AA AA HH HH NN NN ")6print(7 " \x1B[3mS41\x1B[23m/\x1B[3mS42\x1B[23m")8print("")9km_long = 37, 010"""11Lists Descreption:12*ringbahn_stations: 13 -is an Array of 27 Objects each object contaiens 3 items:14 ('name':str(station-name),'duration':int(minutes till nex station),'is_down':bool(station status))15 -ringbahn_stations is called in fromTo() as parameter: stations_list.16 -in duration() this list is sliced and appended to in_between_stations list.17 *temp_list:18 -is an Array with 2 objects tooken from ringbahn_stations.19 -each object contaiens 4 items:20 ('name':str(station-name),'duration':int(minutes till nex station),'is_down':bool(station status),'index':int(position))21 -in fromTo() these 2 objects are given by user start/end input and they get an 'index' key and int(value)22 -in duration() ringbahn_stations is sliced based on temp_list objects index values(end station is excluded), 23 and appended to in_between_stations list.24 *in_between_stations:25 -is an Array with objects sliced from ringbahn_stations based on user start/end input.26 -in_between_stations is called in duration() as parameter: traveled_stations.27 *minutes_list:28 -is an Array of integers, that are tooken from 'duration' values of objects in in_between_stations array of objects.29 -minutes_list is called in duration() as parameter: traveled_minutes30"""31ringbahn_stations = [32 {'name': "Südkreuz", 'duration': 2, 'is_down': False},33 {'name': "Schöneberg", 'duration': 1, 'is_down': False},34 {'name': "Innsbrucker Platz", 'duration': 2, 'is_down': False},35 {'name': "Bundesplatz", 'duration': 2, 'is_down': False},36 {'name': "Heidelberger Platz", 'duration': 2, 'is_down': False},37 {'name': "Hohenzollerndamm", 'duration': 2, 'is_down': False},38 {'name': "Halensee", 'duration': 1, 'is_down': False},39 {'name': "Westkreuz", 'duration': 2, 'is_down': False},40 {'name': "Messe Nord/ICC", 'duration': 2, 'is_down': False},41 {'name': "Westend", 'duration': 3, 'is_down': False},42 {'name': "Jungfernheide", 'duration': 3, 'is_down': False},43 {'name': "Beusselstraße", 'duration': 1, 'is_down': False},44 {'name': "Westhafen", 'duration': 3, 'is_down': False},45 {'name': "Wedding", 'duration': 2, 'is_down': False},46 {'name': "Gesundbrunnen", 'duration': 3, 'is_down': False},47 {'name': "Schönhauser Alle", 'duration': 2, 'is_down': False},48 {'name': "Prenzlauer Alle", 'duration': 2, 'is_down': False},49 {'name': "Greifswalder Straße", 'duration': 2, 'is_down': False},50 {'name': "Landsberger Alle", 'duration': 2, 'is_down': False},51 {'name': "Storkower Straße", 'duration': 2, 'is_down': False},52 {'name': "Frankfurter Alle", 'duration': 2, 'is_down': False},53 {'name': "Ostkreuz", 'duration': 6, 'is_down': False},54 {'name': "Treptower Park", 'duration': 3, 'is_down': False},55 {'name': "Sonnenallee", 'duration': 2, 'is_down': False},56 {'name': "Neukölln", 'duration': 1, 'is_down': False},57 {'name': "Hermannsstraße", 'duration': 4, 'is_down': False},58 {'name': "Tempelhof", 'duration': 2, 'is_down': False}59]60temp_list = []61in_between_stations = []62user_input = ""63"""64-function fromTo takes user input for start/end station and a list of stations(the list is an Array and stations are Objects).65-first loop is counting the elements, starts from 1, index is always 1,66 in every iteration index is added to index_counter depending on list length.67-second loop is iterating over every object in the array.68-checking if user inputs matches any object value in key 'name'.69-appending new 'index' keys to the matched objects with the value (index_counter-1) to get the real object position in the list.70- appending updated objects to a temporary list outside the function71"""72def fromTo(start_input, end_input, stations_list):73 index_counter = 074 start_input = input(">> Departure station: ")75 end_input = input(">> Destination station: ")76 for index in range(1, len(stations_list)):77 for station in stations_list:78 if index_counter < len(stations_list):79 #print(index_counter, station['name'], station['duration'])80 index_counter += index81 if (start_input == station['name']) or (end_input == station['name']):82 # adding index as key:value to start_input/end_input station object83 station['index'] = index_counter-184 # appending updated start_input/end_input object to a temporary list85 temp_list.append(station)86 # print("<< ", index_counter-1,87 # station['name'], station['duration'])88minutes_list = []89"""90-function duration takes two lists as parameters.91-assigning the 'index' key values of temp_list objects in two diffrent variables.92-the difference between the variables is how many stations are in between.93-slicing ringbahn_stations based on the two variables values as slicing indexes and appending them to in_between_stations.94-taking 'duration' key value from in_between_stations objects and appending them in minutes_list.95-adding minutes_list elements together and returning the value96"""97def duration(traveled_stations, traveled_minutes):98 start = temp_list[0]['index']99 end = temp_list[1]['index']100 print("<< Stations till destination:", end - start)101 # slicing ringbahn stations list depending on the index values of the objects in temp_list102 traveled_stations.append(ringbahn_stations[start:end])103 # print(*traveled_stations[0])104 counter = 0105 duration_time = 0106 for i in range(0, len(traveled_stations[0])):107 for stations in traveled_stations:108 if counter < len(traveled_stations[0]):109 counter += 1110 duration_time = stations[i]['duration']111 traveled_minutes.append(duration_time)112 # print(traveled_minutes)113 minutes = 0114 for elements in traveled_minutes:115 minutes += elements116 return minutes117fromTo(user_input, user_input, ringbahn_stations)118print("<< Travel time:", duration(in_between_stations, minutes_list), "minutes")119# print(ringbahn_stations[24]['name'], ringbahn_stations[24]['duration'],...

Full Screen

Full Screen

test_inputs.py

Source:test_inputs.py Github

copy

Full Screen

...14 pygame.init()15 controller = GamecubeController(controller_id=0)16 controller.read_new_inputs()17 assert controller[0] == (1, 0)18 assert controller.is_down(gamecube.A) == 119 assert controller.is_down(gamecube.B) == 020 assert controller.A.is_down == 121 assert controller.B.is_down == 022@patch("pygame.joystick.Joystick")23@patch("robingame.input.gamecube.GamecubeControllerReader.get_values")24def test_gamecube_controller_subclasses(mock_get_values, mock_joystick):25 mock_get_values.return_value = (1, 0) # A down, B not down26 pygame.init()27 class Subclass(GamecubeController):28 A2 = ButtonInput(gamecube.A)29 class Subclass2(Subclass):30 A3 = ButtonInput(gamecube.A)31 class Subclass3(GamecubeController):32 B2 = ButtonInput(gamecube.B)33 subclass = Subclass(controller_id=0)34 subclass.read_new_inputs()35 assert subclass[0] == (1, 0)36 assert subclass.is_down(gamecube.A) == 137 assert subclass.is_down(gamecube.B) == 038 assert subclass.A.is_down == 139 assert subclass.A2.is_down == 140 with pytest.raises(AttributeError):41 assert subclass.A3.is_down == 142 with pytest.raises(AttributeError):43 assert subclass.B2.is_down == 144 assert subclass.B.is_down == 045 subclass2 = Subclass2(controller_id=0)46 subclass2.read_new_inputs()47 assert subclass2[0] == (1, 0)48 assert subclass2.is_down(gamecube.A) == 149 assert subclass2.is_down(gamecube.B) == 050 assert subclass2.A.is_down == 151 assert subclass2.A2.is_down == 152 assert subclass2.A3.is_down == 153 with pytest.raises(AttributeError):54 assert subclass.B2.is_down == 155 assert subclass2.B.is_down == 056 subclass3 = Subclass3(controller_id=0)57 subclass3.read_new_inputs()58 assert subclass3[0] == (1, 0)59 assert subclass3.is_down(gamecube.A) == 160 assert subclass3.is_down(gamecube.B) == 061 assert subclass3.A.is_down == 162 with pytest.raises(AttributeError):63 assert subclass3.A2.is_down == 164 with pytest.raises(AttributeError):65 assert subclass3.A3.is_down == 166 assert subclass3.B.is_down == 067 assert subclass3.B2.is_down == 068@pytest.mark.parametrize(69 "input, expected_rising_edges, expected_falling_edges",70 [71 ([], 0, 0), # no buffered values shouldn't crash things72 ([0, 0, 0], 0, 0), # some values but less than the buffer73 ([0, 0, 1], 1, 0),74 ([1, 0, 0], 0, 1),...

Full Screen

Full Screen

test_modifierbuttons.py

Source:test_modifierbuttons.py Github

copy

Full Screen

...4 btns = ModifierButtons()5 assert btns == ModifierButtons(btns)6 assert btns != ModifierButtons()7 assert btns.matches(ModifierButtons())8 assert not btns.is_down("alt")9 assert not btns.is_any_down()10 assert not btns.has_button("alt")11 assert btns.get_prefix() == ""12 assert btns.get_num_buttons() == 013 assert len(btns.buttons) == 014def test_modifierbuttons_cow():15 # Tests the copy-on-write mechanism of the button list.16 btns1 = ModifierButtons()17 btns1.add_button("space")18 # Modifying original should not affect copy19 btns2 = ModifierButtons(btns1)20 assert tuple(btns2.buttons) == tuple(btns1.buttons)21 btns1.add_button("enter")22 assert tuple(btns1.buttons) == ("space", "enter")23 assert tuple(btns2.buttons) == ("space",)24 # Modifying copy should not affect original25 btns3 = ModifierButtons(btns2)26 assert tuple(btns3.buttons) == tuple(btns2.buttons)27 btns3.add_button("escape")28 assert tuple(btns2.buttons) == ("space",)29 assert tuple(btns3.buttons) == ("space", "escape")30def test_modifierbuttons_assign():31 # Tests assignment operator.32 btns1 = ModifierButtons()33 btns1.add_button("space")34 btns2 = ModifierButtons()35 btns2.assign(btns1)36 assert btns1 == btns237 assert tuple(btns1.buttons) == tuple(btns2.buttons)38def test_modifierbuttons_state():39 btns = ModifierButtons()40 btns.add_button("alt")41 btns.add_button("shift")42 btns.add_button("control")43 assert not btns.is_any_down()44 # Not tracked45 btns.button_down("enter")46 assert not btns.is_any_down()47 # Tracked48 btns.button_down("shift")49 assert btns.is_any_down()50 assert not btns.is_down(0)51 assert btns.is_down(1)52 assert not btns.is_down(2)53 btns.button_up("shift")54 assert not btns.is_any_down()55 assert not btns.is_down(0)56 assert not btns.is_down(1)57 assert not btns.is_down(2)58 btns.button_down("alt")59 btns.button_down("shift")60 assert btns.is_any_down()61 assert btns.is_down(0)62 assert btns.is_down(1)63 assert not btns.is_down(2)64 btns.all_buttons_up()65 assert not btns.is_any_down()66 assert not btns.is_down(0)67 assert not btns.is_down(1)...

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 autotest 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