Best Python code snippet using locust
test_runners.py
Source:test_runners.py
...429 sleep(0)430 self.assertEqual(0, len(master.clients.all))431 self.assertEqual(STATE_STOPPED, master.state, "All workers quit but test didn't stop.")432 @mock.patch("locust.runners.HEARTBEAT_INTERVAL", new=0.1)433 def test_last_worker_missing_stops_test(self):434 with mock.patch("locust.rpc.rpc.Server", mocked_rpc()) as server:435 master = self.get_runner()436 server.mocked_send(Message("client_ready", None, "fake_client1"))437 server.mocked_send(Message("client_ready", None, "fake_client2"))438 master.start(1, 2)439 server.mocked_send(Message("hatching", None, "fake_client1"))440 server.mocked_send(Message("hatching", None, "fake_client2"))441 sleep(0.3)442 server.mocked_send(Message("heartbeat", {'state': STATE_RUNNING, 'current_cpu_usage': 50}, "fake_client1"))443 sleep(0.3)444 self.assertEqual(1, len(master.clients.missing))445 self.assertNotEqual(STATE_STOPPED, master.state, "Not all workers went missing but test stopped anyway.")446 sleep(0.3)447 self.assertEqual(2, len(master.clients.missing))...
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!!