Best Python code snippet using locust
test_dispatch.py
Source:test_dispatch.py
...1780 User48,1781 User49,1782 User50,1783 ]1784 def test_distribute_users(self):1785 workers = [WorkerNode(str(i)) for i in range(10_000)]1786 target_user_count = 1_000_0001787 users_dispatcher = UsersDispatcher(worker_nodes=workers, user_classes=self.user_classes)1788 ts = time.perf_counter()1789 users_on_workers, user_gen, worker_gen, active_users = users_dispatcher._distribute_users(1790 target_user_count=target_user_count1791 )1792 delta = time.perf_counter() - ts1793 # Because tests are run with coverage, the code will be slower.1794 # We set the pass criterion to 5000ms, but in real life, the1795 # `_distribute_users` method runs faster than this.1796 self.assertLessEqual(1000 * delta, 5000)1797 self.assertEqual(_user_count(users_on_workers), target_user_count)1798 def test_ramp_up_from_0_to_100_000_users_with_50_user_classes_and_1000_workers_and_5000_spawn_rate(self):...
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!!