How to use reset_mock method in autotest

Best Python code snippet using autotest_python

test_ecobee.py

Source:test_ecobee.py Github

copy

Full Screen

...223 self.ecobee['equipmentStatus'] = 'fan, auxHeat'224 assert self.thermostat.is_aux_heat_on225 def test_turn_away_mode_on_off(self):226 """Test turn away mode setter."""227 self.data.reset_mock()228 # Turn on first while the current hold mode is not away hold229 self.thermostat.turn_away_mode_on()230 self.data.ecobee.set_climate_hold.assert_has_calls(231 [mock.call(1, 'away', 'indefinite')])232 # Try with away hold233 self.data.reset_mock()234 self.ecobee['events'][0]['endDate'] = '2019-01-01 11:12:12'235 # Should not call set_climate_hold()236 assert not self.data.ecobee.set_climate_hold.called237 # Try turning off while hold mode is away hold238 self.data.reset_mock()239 self.thermostat.turn_away_mode_off()240 self.data.ecobee.resume_program.assert_has_calls([mock.call(1)])241 # Try turning off when it has already been turned off242 self.data.reset_mock()243 self.ecobee['events'][0]['endDate'] = '2017-01-01 14:00:00'244 self.thermostat.turn_away_mode_off()245 assert not self.data.ecobee.resume_program.called246 def test_set_hold_mode(self):247 """Test hold mode setter."""248 # Test same hold mode249 # Away->Away250 self.data.reset_mock()251 self.thermostat.set_hold_mode('away')252 assert not self.data.ecobee.delete_vacation.called253 assert not self.data.ecobee.resume_program.called254 assert not self.data.ecobee.set_hold_temp.called255 assert not self.data.ecobee.set_climate_hold.called256 # Away->'None'257 self.data.reset_mock()258 self.thermostat.set_hold_mode('None')259 assert not self.data.ecobee.delete_vacation.called260 self.data.ecobee.resume_program.assert_has_calls([mock.call(1)])261 assert not self.data.ecobee.set_hold_temp.called262 assert not self.data.ecobee.set_climate_hold.called263 # Vacation Hold -> None264 self.ecobee['events'][0]['type'] = 'vacation'265 self.data.reset_mock()266 self.thermostat.set_hold_mode(None)267 self.data.ecobee.delete_vacation.assert_has_calls(268 [mock.call(1, 'Event1')])269 assert not self.data.ecobee.resume_program.called270 assert not self.data.ecobee.set_hold_temp.called271 assert not self.data.ecobee.set_climate_hold.called272 # Away -> home, sleep273 for hold in ['home', 'sleep']:274 self.data.reset_mock()275 self.thermostat.set_hold_mode(hold)276 assert not self.data.ecobee.delete_vacation.called277 assert not self.data.ecobee.resume_program.called278 assert not self.data.ecobee.set_hold_temp.called279 self.data.ecobee.set_climate_hold.assert_has_calls(280 [mock.call(1, hold, 'nextTransition')])281 # Away -> temp282 self.data.reset_mock()283 self.thermostat.set_hold_mode('temp')284 assert not self.data.ecobee.delete_vacation.called285 assert not self.data.ecobee.resume_program.called286 self.data.ecobee.set_hold_temp.assert_has_calls(287 [mock.call(1, 35.0, 25.0, 'nextTransition')])288 assert not self.data.ecobee.set_climate_hold.called289 def test_set_auto_temp_hold(self):290 """Test auto temp hold setter."""291 self.data.reset_mock()292 self.thermostat.set_auto_temp_hold(20.0, 30)293 self.data.ecobee.set_hold_temp.assert_has_calls(294 [mock.call(1, 30, 20.0, 'nextTransition')])295 def test_set_temp_hold(self):296 """Test temp hold setter."""297 # Away mode or any mode other than heat or cool298 self.data.reset_mock()299 self.thermostat.set_temp_hold(30.0)300 self.data.ecobee.set_hold_temp.assert_has_calls(301 [mock.call(1, 35.0, 25.0, 'nextTransition')])302 # Heat mode303 self.data.reset_mock()304 self.ecobee['settings']['hvacMode'] = 'heat'305 self.thermostat.set_temp_hold(30)306 self.data.ecobee.set_hold_temp.assert_has_calls(307 [mock.call(1, 30, 30, 'nextTransition')])308 # Cool mode309 self.data.reset_mock()310 self.ecobee['settings']['hvacMode'] = 'cool'311 self.thermostat.set_temp_hold(30)312 self.data.ecobee.set_hold_temp.assert_has_calls(313 [mock.call(1, 30, 30, 'nextTransition')])314 def test_set_temperature(self):315 """Test set temperature."""316 # Auto -> Auto317 self.data.reset_mock()318 self.thermostat.set_temperature(target_temp_low=20,319 target_temp_high=30)320 self.data.ecobee.set_hold_temp.assert_has_calls(321 [mock.call(1, 30, 20, 'nextTransition')])322 # Auto -> Hold323 self.data.reset_mock()324 self.thermostat.set_temperature(temperature=20)325 self.data.ecobee.set_hold_temp.assert_has_calls(326 [mock.call(1, 25, 15, 'nextTransition')])327 # Cool -> Hold328 self.data.reset_mock()329 self.ecobee['settings']['hvacMode'] = 'cool'330 self.thermostat.set_temperature(temperature=20.5)331 self.data.ecobee.set_hold_temp.assert_has_calls(332 [mock.call(1, 20.5, 20.5, 'nextTransition')])333 # Heat -> Hold334 self.data.reset_mock()335 self.ecobee['settings']['hvacMode'] = 'heat'336 self.thermostat.set_temperature(temperature=20)337 self.data.ecobee.set_hold_temp.assert_has_calls(338 [mock.call(1, 20, 20, 'nextTransition')])339 # Heat -> Auto340 self.data.reset_mock()341 self.ecobee['settings']['hvacMode'] = 'heat'342 self.thermostat.set_temperature(target_temp_low=20,343 target_temp_high=30)344 assert not self.data.ecobee.set_hold_temp.called345 def test_set_operation_mode(self):346 """Test operation mode setter."""347 self.data.reset_mock()348 self.thermostat.set_operation_mode('auto')349 self.data.ecobee.set_hvac_mode.assert_has_calls(350 [mock.call(1, 'auto')])351 self.data.reset_mock()352 self.thermostat.set_operation_mode('heat')353 self.data.ecobee.set_hvac_mode.assert_has_calls(354 [mock.call(1, 'heat')])355 def test_set_fan_min_on_time(self):356 """Test fan min on time setter."""357 self.data.reset_mock()358 self.thermostat.set_fan_min_on_time(15)359 self.data.ecobee.set_fan_min_on_time.assert_has_calls(360 [mock.call(1, 15)])361 self.data.reset_mock()362 self.thermostat.set_fan_min_on_time(20)363 self.data.ecobee.set_fan_min_on_time.assert_has_calls(364 [mock.call(1, 20)])365 def test_resume_program(self):366 """Test resume program."""367 # False368 self.data.reset_mock()369 self.thermostat.resume_program(False)370 self.data.ecobee.resume_program.assert_has_calls(371 [mock.call(1, 'false')])372 self.data.reset_mock()373 self.thermostat.resume_program(None)374 self.data.ecobee.resume_program.assert_has_calls(375 [mock.call(1, 'false')])376 self.data.reset_mock()377 self.thermostat.resume_program(0)378 self.data.ecobee.resume_program.assert_has_calls(379 [mock.call(1, 'false')])380 # True381 self.data.reset_mock()382 self.thermostat.resume_program(True)383 self.data.ecobee.resume_program.assert_has_calls(384 [mock.call(1, 'true')])385 self.data.reset_mock()386 self.thermostat.resume_program(1)387 self.data.ecobee.resume_program.assert_has_calls(388 [mock.call(1, 'true')])389 def test_hold_preference(self):390 """Test hold preference."""391 assert 'nextTransition' == self.thermostat.hold_preference()392 for action in ['useEndTime4hour', 'useEndTime2hour',393 'nextPeriod', 'indefinite', 'askMe']:394 self.ecobee['settings']['holdAction'] = action395 assert 'nextTransition' == \396 self.thermostat.hold_preference()397 def test_climate_list(self):398 """Test climate list property."""399 assert ['Climate1', 'Climate2'] == \400 self.thermostat.climate_list401 def test_set_fan_mode_on(self):402 """Test set fan mode to on."""403 self.data.reset_mock()404 self.thermostat.set_fan_mode('on')405 self.data.ecobee.set_fan_mode.assert_has_calls(406 [mock.call(1, 'on', 20, 40, 'nextTransition')])407 def test_set_fan_mode_auto(self):408 """Test set fan mode to auto."""409 self.data.reset_mock()410 self.thermostat.set_fan_mode('auto')411 self.data.ecobee.set_fan_mode.assert_has_calls(...

Full Screen

Full Screen

test_tasks.py

Source:test_tasks.py Github

copy

Full Screen

...38 with mock.patch(PIPELINE_PROCESS_GET, self.get_alive_process):39 tasks.process_unfreeze(self.alive_process.id)40 self.get_alive_process.assert_called_with(id=self.alive_process.id)41 runtime.run_loop.assert_called_with(self.alive_process)42 runtime.run_loop.reset_mock()43 # dead process44 with mock.patch(PIPELINE_PROCESS_GET, self.get_not_alive_process):45 tasks.process_unfreeze(self.not_alive_process.id)46 self.get_not_alive_process.assert_called_with(id=self.not_alive_process.id)47 runtime.run_loop.assert_not_called()48 @mock.patch(ENGINE_RUN_LOOP, mock.MagicMock())49 @mock.patch(PIPELINE_STATUS_TRANSIT, mock.MagicMock())50 @mock.patch(PIPELINE_NODE_RELATIONSHIP_BUILD, mock.MagicMock())51 def test_start(self):52 # dead process53 with mock.patch(PIPELINE_PROCESS_GET, self.get_not_alive_process):54 tasks.start(self.not_alive_process.id)55 self.get_not_alive_process.assert_called_with(id=self.not_alive_process.id)56 Status.objects.transit.assert_not_called()57 NodeRelationship.objects.build_relationship.assert_not_called()58 runtime.run_loop.assert_not_called()59 # alive process60 with mock.patch(PIPELINE_PROCESS_GET, self.get_alive_process):61 # transit success62 with mock.patch(PIPELINE_STATUS_TRANSIT, self.transit_success):63 tasks.start(self.alive_process.id)64 self.get_alive_process.assert_called_with(id=self.alive_process.id)65 self.transit_success.assert_called_with(66 self.alive_process.root_pipeline.id, states.RUNNING, is_pipeline=True, start=True67 )68 NodeRelationship.objects.build_relationship.assert_called_with(69 self.alive_process.root_pipeline.id, self.alive_process.root_pipeline.id70 )71 runtime.run_loop.assert_called_with(self.alive_process)72 self.get_alive_process.reset_mock()73 self.transit_success.reset_mock()74 NodeRelationship.objects.build_relationship.reset_mock()75 runtime.run_loop.reset_mock()76 # transit failed77 with mock.patch(PIPELINE_STATUS_TRANSIT, self.transit_fail):78 tasks.start(self.alive_process.id)79 self.get_alive_process.assert_called_with(id=self.alive_process.id)80 self.transit_fail.assert_called_with(81 self.alive_process.root_pipeline.id, states.RUNNING, is_pipeline=True, start=True82 )83 NodeRelationship.objects.build_relationship.assert_not_called()84 runtime.run_loop.assert_not_called()85 @mock.patch(ENGINE_RUN_LOOP, mock.MagicMock())86 def test_dispatch(self):87 # alive process88 with mock.patch(PIPELINE_PROCESS_GET, self.get_alive_process):89 tasks.dispatch(self.alive_process.id)90 self.get_alive_process.assert_called_with(id=self.alive_process.id)91 runtime.run_loop.assert_called_with(self.alive_process)92 self.get_not_alive_process.reset_mock()93 runtime.run_loop.reset_mock()94 # dead process95 with mock.patch(PIPELINE_PROCESS_GET, self.get_not_alive_process):96 tasks.dispatch(self.not_alive_process.id)97 self.get_not_alive_process.assert_called_with(id=self.not_alive_process.id)98 runtime.run_loop.assert_not_called()99 @mock.patch(ENGINE_RUN_LOOP, mock.MagicMock())100 @mock.patch(PIPELINE_STATUS_TRANSIT, mock.MagicMock())101 def test_process_wake_up(self):102 # dead process103 with mock.patch(PIPELINE_PROCESS_GET, self.get_not_alive_process):104 for current_node_id, call_from_child in itertools.product((uniqid(), None), (True, False)):105 self.get_not_alive_process.reset_mock()106 tasks.process_wake_up(107 self.not_alive_process.id, current_node_id=current_node_id, call_from_child=call_from_child108 )109 self.get_not_alive_process.assert_called_with(id=self.not_alive_process.id)110 Status.objects.transit.assert_not_called()111 self.not_alive_process.wake_up.assert_not_called()112 runtime.run_loop.assert_not_called()113 # alive process114 with mock.patch(PIPELINE_PROCESS_GET, self.get_alive_process):115 # call from child116 tasks.process_wake_up(self.alive_process.id, current_node_id=None, call_from_child=True)117 self.get_alive_process.assert_called_with(id=self.alive_process.id)118 Status.objects.transit.assert_not_called()119 self.alive_process.wake_up.assert_called()120 self.assertIsNone(self.alive_process.current_node_id)121 runtime.run_loop.assert_called_with(self.alive_process)122 self.get_alive_process.reset_mock()123 self.alive_process.wake_up.reset_mock()124 runtime.run_loop.reset_mock()125 # has current_node_id126 current_node_id = uniqid()127 tasks.process_wake_up(self.alive_process.id, current_node_id=current_node_id, call_from_child=True)128 self.get_alive_process.assert_called_with(id=self.alive_process.id)129 Status.objects.transit.assert_not_called()130 self.alive_process.wake_up.assert_called()131 self.assertEqual(self.alive_process.current_node_id, current_node_id)132 runtime.run_loop.assert_called_with(self.alive_process)133 self.get_alive_process.reset_mock()134 self.alive_process.wake_up.reset_mock()135 runtime.run_loop.reset_mock()136 self.alive_process.current_node_id = None137 # not call from child138 with mock.patch(PIPELINE_STATUS_TRANSIT, self.transit_success):139 # transit success140 tasks.process_wake_up(self.alive_process.id, current_node_id=None, call_from_child=False)141 self.get_alive_process.assert_called_with(id=self.alive_process.id)142 self.transit_success.assert_called_with(143 self.alive_process.root_pipeline.id, to_state=states.RUNNING, is_pipeline=True, unchanged_pass=True144 )145 self.alive_process.wake_up.assert_called()146 self.assertIsNone(self.alive_process.current_node_id)147 runtime.run_loop.assert_called_with(self.alive_process)148 self.get_alive_process.reset_mock()149 self.alive_process.wake_up.reset_mock()150 runtime.run_loop.reset_mock()151 with mock.patch(PIPELINE_STATUS_TRANSIT, self.transit_fail_and_return_suspended):152 # transit failed153 tasks.process_wake_up(self.alive_process.id, current_node_id=None, call_from_child=False)154 self.get_alive_process.assert_called_with(id=self.alive_process.id)155 self.transit_fail_and_return_suspended.assert_called_with(156 self.alive_process.root_pipeline.id, to_state=states.RUNNING, is_pipeline=True, unchanged_pass=True157 )158 self.alive_process.wake_up.assert_not_called()159 self.assertIsNone(self.alive_process.current_node_id)160 runtime.run_loop.assert_not_called()161 with mock.patch(PIPELINE_STATUS_TRANSIT, self.transit_fail_and_return_blocked):162 # transit failed but in blocked state163 tasks.process_wake_up(self.alive_process.id, current_node_id=None, call_from_child=False)164 self.get_alive_process.assert_called_with(id=self.alive_process.id)165 self.transit_fail_and_return_blocked.assert_called_with(166 self.alive_process.root_pipeline.id, to_state=states.RUNNING, is_pipeline=True, unchanged_pass=True167 )168 self.alive_process.wake_up.assert_called()169 self.assertIsNone(self.alive_process.current_node_id)170 runtime.run_loop.assert_called_with(self.alive_process)171 @mock.patch(ENGINE_RUN_LOOP, mock.MagicMock())172 def test_wake_up(self):173 # alive process174 with mock.patch(PIPELINE_PROCESS_GET, self.get_alive_process):175 tasks.wake_up(self.alive_process.id)176 self.get_alive_process.assert_called_with(id=self.alive_process.id)177 self.alive_process.wake_up.assert_called()178 runtime.run_loop.assert_called_with(self.alive_process)179 self.get_not_alive_process.reset_mock()180 self.alive_process.wake_up.reset_mock()181 runtime.run_loop.reset_mock()182 # dead process183 with mock.patch(PIPELINE_PROCESS_GET, self.get_not_alive_process):184 tasks.wake_up(self.not_alive_process.id)185 self.get_not_alive_process.assert_called_with(id=self.not_alive_process.id)186 self.not_alive_process.wake_up.assert_not_called()187 runtime.run_loop.assert_not_called()188 @mock.patch(ENGINE_TASKS_WAKE_UP_APPLY, mock.MagicMock(return_value=IdentifyObject(id="task_id")))189 @mock.patch(PIPELINE_CELERYTASK_BIND, mock.MagicMock())190 def test_batch_wake_up(self):191 process_id_list = [uniqid() for _ in range(5)]192 # transit success193 with mock.patch(PIPELINE_STATUS_TRANSIT, self.transit_success):194 tasks.batch_wake_up(process_id_list, self.alive_process.root_pipeline.id)195 self.transit_success.assert_called_with(196 self.alive_process.root_pipeline.id, to_state=states.RUNNING, is_pipeline=True197 )198 tasks.wake_up.apply_async.assert_has_calls([mock.call(args=[pid]) for pid in process_id_list])199 ProcessCeleryTask.objects.bind.assert_has_calls([mock.call(pid, "task_id") for pid in process_id_list])200 tasks.wake_up.apply_async.reset_mock()201 ProcessCeleryTask.objects.bind.reset_mock()202 # transit fail203 with mock.patch(PIPELINE_STATUS_TRANSIT, self.transit_fail):204 tasks.batch_wake_up(process_id_list, self.alive_process.root_pipeline.id)205 self.transit_fail.assert_called_with(206 self.alive_process.root_pipeline.id, to_state=states.RUNNING, is_pipeline=True207 )208 tasks.wake_up.apply_async.assert_not_called()209 ProcessCeleryTask.objects.bind.assert_not_called()210 @mock.patch(ENGINE_RUN_LOOP, mock.MagicMock())211 def test_wake_from_schedule(self):212 with mock.patch(PIPELINE_PROCESS_GET, self.get_alive_process):213 tasks.wake_from_schedule(self.alive_process.id, None)214 self.get_alive_process.assert_called_with(id=self.alive_process.id)215 self.alive_process.wake_up.assert_called()216 self.assertEqual(self.alive_process.current_node_id, self.alive_process.top_pipeline.node(None).next().id)217 runtime.run_loop.assert_called_with(self.alive_process)218 @mock.patch(ENGINE_SCHEDULE, mock.MagicMock())219 def test_service_schedule(self):220 process_id = uniqid()221 schedule_id = uniqid()222 data_id = None223 tasks.service_schedule(process_id, schedule_id, data_id)224 schedule.schedule.assert_called_with(process_id, schedule_id, data_id)225 @mock.patch(PIPELINE_NODE_CELERYTASK_DESTROY, mock.MagicMock())226 @mock.patch(ENGINE_API_FORCED_FAIL, mock.MagicMock())227 @mock.patch(ENGINE_ACTIVITY_FAIL_SIGNAL, mock.MagicMock())228 def test_node_timeout_check(self):229 # state for return None230 with mock.patch(PIPELINE_STATUS_STATE_FOR, mock.MagicMock(return_value=None)):231 node_id = uniqid()232 version = uniqid()233 root_pipeline_id = uniqid()234 tasks.node_timeout_check(node_id, version, root_pipeline_id)235 NodeCeleryTask.objects.destroy.assert_called_with(node_id)236 Status.objects.state_for.assert_called_with(node_id, version=version, may_not_exist=True)237 api.forced_fail.assert_not_called()238 for state_not_running in states.ALL_STATES.difference({states.RUNNING}):239 NodeCeleryTask.objects.destroy.reset_mock()240 api.forced_fail.reset_mock()241 # state for return other values242 with mock.patch(PIPELINE_STATUS_STATE_FOR, mock.MagicMock(return_value=state_not_running)):243 node_id = uniqid()244 version = uniqid()245 root_pipeline_id = uniqid()246 tasks.node_timeout_check(node_id, version, root_pipeline_id)247 NodeCeleryTask.objects.destroy.assert_called_with(node_id)248 Status.objects.state_for.assert_called_with(node_id, version=version, may_not_exist=True)249 api.forced_fail.assert_not_called()250 NodeCeleryTask.objects.destroy.reset_mock()251 api.forced_fail.reset_mock()252 # state for return RUNNING253 with mock.patch(PIPELINE_STATUS_STATE_FOR, mock.MagicMock(return_value=states.RUNNING)):254 # force fail success255 with mock.patch(ENGINE_API_FORCED_FAIL, mock.MagicMock(return_value=MockActionResult(result=True))):256 node_id = uniqid()257 version = uniqid()258 root_pipeline_id = uniqid()259 tasks.node_timeout_check(node_id, version, root_pipeline_id)260 NodeCeleryTask.objects.destroy.assert_called_with(node_id)261 Status.objects.state_for.assert_called_with(node_id, version=version, may_not_exist=True)262 api.forced_fail.assert_called_with(node_id, kill=True, ex_data="node execution timeout")263 signals.activity_failed.send.assert_called_with(264 sender=Pipeline, pipeline_id=root_pipeline_id, pipeline_activity_id=node_id265 )266 NodeCeleryTask.objects.destroy.reset_mock()267 Status.objects.state_for.reset_mock()268 api.forced_fail.reset_mock()269 signals.activity_failed.send.reset_mock()270 # force fail failed271 with mock.patch(ENGINE_API_FORCED_FAIL, mock.MagicMock(return_value=MockActionResult(result=False))):272 node_id = uniqid()273 version = uniqid()274 root_pipeline_id = uniqid()275 tasks.node_timeout_check(node_id, version, root_pipeline_id)276 NodeCeleryTask.objects.destroy.assert_called_with(node_id)277 Status.objects.state_for.assert_called_with(node_id, version=version, may_not_exist=True)278 api.forced_fail.assert_called_with(node_id, kill=True, ex_data="node execution timeout")...

Full Screen

Full Screen

test_events.py

Source:test_events.py Github

copy

Full Screen

...12 events.on('ev2', f2)13 events.fire('ev1', 123, value=456)14 self.assertEqual(f1.call_args, ((123,), {'value': 456}))15 self.assertFalse(f2.called)16 f1.reset_mock()17 f2.reset_mock()18 events.fire('ev2', 7788, v=9988)19 self.assertEqual(f1.call_args, ((7788,), {'v': 9988}))20 self.assertEqual(f2.call_args, ((7788,), {'v': 9988}))21 f1.reset_mock()22 f2.reset_mock()23 events.off('ev2', f1)24 events.fire('ev2', 999, k=888)25 self.assertFalse(f1.called)26 self.assertEqual(f2.call_args, ((999,), {'k': 888}))27 events.fire('ev1', 321, value=654)28 self.assertEqual(f1.call_args, ((321,), {'value': 654}))29 events = EventSource(['ev1'])30 events.on('ev1', f1)31 f1.reset_mock()32 events.fire('ev1', 123, value=456)33 self.assertEqual(f1.call_args, ((123,), {'value': 456}))34 def test_order(self):35 dest = []36 def f(x):37 dest.append(x)38 events = EventSource()39 events.on('ev', lambda: f(1))40 events.on('ev', lambda: f(2))41 events.on('ev', lambda: f(3))42 events.fire('ev')43 self.assertListEqual(dest, [1, 2, 3])44 del dest[:]45 events.reverse_fire('ev')46 self.assertListEqual(dest, [3, 2, 1])47 def test_clear(self):48 f1 = Mock()49 f2 = Mock()50 events = EventSource()51 events.on('ev1', f1)52 events.on('ev1', f2)53 events.on('ev2', f1)54 events.on('ev2', f2)55 events.on('ev3', f1)56 events.on('ev3', f2)57 events.fire('ev1')58 events.fire('ev2')59 events.fire('ev3')60 self.assertEqual(f1.call_count, 3)61 self.assertEqual(f2.call_count, 3)62 f1.reset_mock()63 f2.reset_mock()64 events.clear_event_handlers('ev1')65 events.clear_event_handlers('ev4')66 events.fire('ev1')67 events.fire('ev2')68 events.fire('ev3')69 self.assertEqual(f1.call_count, 2)70 self.assertEqual(f2.call_count, 2)71 f1.reset_mock()72 f2.reset_mock()73 events.clear_event_handlers()74 events.fire('ev1')75 events.fire('ev2')76 events.fire('ev3')77 self.assertEqual(f1.call_count, 0)78 self.assertEqual(f2.call_count, 0)79 def test_errors(self):80 f = Mock()81 events = EventSource(['ev1'])82 with pytest.raises(KeyError, match='`event_key` is not allowed'):83 events.on('ev2', f)84 with pytest.raises(KeyError, match='`event_key` is not allowed'):85 events.fire('ev2', 123, value=456)86 with pytest.raises(ValueError, match='`handler` is not a registered '...

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