

def test_middleware_can_access_user_when_processing_response(self):
    user = User.objects.create_user('john', 'john@example.com', 'password')
    key = 'abcd1234'
    Token.objects.create(key=key, user=user)
    with self.settings(MIDDLEWARE_CLASSES=('tests.test_middleware.MyMiddleware',)):
        auth = ('Token ' + key)
        self.client.get('/', HTTP_AUTHORIZATION=auth)

dataset/ETHPy150Open tomchristie/django-rest-framework/tests/test_middleware.py TestMiddleware.test_middleware_can_access_user_when_processing_response/original