'Tests that we can accurately spawn a certain number of locusts, even if it\'s not an
even number of the connected slaves'

def test_spawn_uneven_locusts(self):

    import mock
    class MyTestLocust(Locust, ):
        pass
    with mock.patch('locust.rpc.rpc.Server', mocked_rpc_server()) as server:
        master = MasterLocustRunner(MyTestLocust, self.options)
        for i in range(5):
            server.mocked_send(Message('client_ready', None, ('fake_client%i' % i)))
            sleep(0)
        master.start_hatching(7, 7)
        self.assertEqual(5, len(server.outbox))
        num_clients = 0
        for msg in server.outbox:
            num_clients += Message.unserialize(msg).data['num_clients']
        self.assertEqual(7, num_clients, 'Total    number    of    locusts    that    would    have    been    spawned    is    not    7')
