I like django and the more I work with it, the more I like it 🙂
For a unittest I needed to simulate requests coming from different remote addresses. And the django.test.client.Client makes this pretty easy:
class DistributedTestClient(Client): def request(self, **request): request["REMOTE_ADDR"] = "192.168.%i.%i" % (random.randint(1,254), random.randint(1,254)) return super(DistributedTestClient, self).request(**request) class DistributedClientkTestCase(TestCase): client_class = DistributedTestClient def test_distributed_meep(self): test_stuff()
Thanks django!
Leave a Reply