SHARE
TWEET

Untitled

a guest Jan 11th, 2017 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.test import TestCase
  2.  
  3. class FooTests(TestCase):
  4.     def test_bar(self):
  5.         self.client.get('/', HTTP_HOST='example.com')
  6.    
  7. from django.test import TestCase
  8. from django.test.client import Client
  9.  
  10.  
  11. class MyClient(Client):
  12.     HTTP_HOST = 'example.com'
  13.  
  14.     def get(self, *args, **kwargs):
  15.         kwargs.setdefault('HTTP_HOST', self.HTTP_HOST)
  16.         return super(MyClient, self).get(*args, **kwargs)
  17.  
  18.  
  19. class MyTestCase(TestCase):
  20.     client_class = MyClient
  21.  
  22.  
  23. class FooTests(MyTestCase):
  24.     def test_foo(self):
  25.         self.client.get('/')
RAW Paste Data
Top