  
  
  @api_view(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'])
  def view(request):
      return Response({
          'auth': request.META.get('HTTP_AUTHORIZATION', b''),
          'user': request.user.username
      })
  
  
  @api_view(['GET', 'POST'])
  def session_view(request):
      active_session = request.session.get('active_session', False)
 
</s> remove     def test_force_authenticate(self):
 </s> add     def test_force_authenticate_with_user(self): </s> remove         self.client.force_authenticate(user)
 </s> add         self.client.force_authenticate(user=user)
        response = self.client.get('/view/')

        assert response.data['user'] == 'example'
        assert 'token' not in response.data

    def test_force_authenticate_with_token(self):
        """
        Setting `.force_authenticate()` with a token forcibly authenticates each
        request with that token.
        """
        user = User.objects.create_user('example', 'example@example.com')
        token = Token.objects.create(key='xyz', user=user)

        self.client.force_authenticate(token=token) </s> remove         Setting `.force_authenticate()` forcibly authenticates each request.
 </s> add         Setting `.force_authenticate()` with a user forcibly authenticates each
        request with that user.
    data = {'auth': request.META.get('HTTP_AUTHORIZATION', b'')}
    if request.user:
        data['user'] = request.user.username
    if request.auth:
        data['token'] = request.auth.key
    return Response(data)
  
  
  @api_view(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'])
  def view(request):
    data = {'auth': request.META.get('HTTP_AUTHORIZATION', b'')}
    if request.user:
        data['user'] = request.user.username
    if request.auth:
        data['token'] = request.auth.key
    return Response(data)
    data = {'auth': request.META.get('HTTP_AUTHORIZATION', b'')}
    if request.user:
        data['user'] = request.user.username
    if request.auth:
        data['token'] = request.auth.key
    return Response(data)
    data = {'auth': request.META.get('HTTP_AUTHORIZATION', b'')}
    if request.user:
        data['user'] = request.user.username
    if request.auth:
        data['token'] = request.auth.key
    return Response(data)
    data = {'auth': request.META.get('HTTP_AUTHORIZATION', b'')}
    if request.user:
        data['user'] = request.user.username
    if request.auth:
        data['token'] = request.auth.key
    return Response(data)
  
  
  @api_view(['GET', 'POST'])
  def session_view(request):
      active_session = request.session.get('active_session', False)
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Make `APIClient.force_authenticate()` work with `user=None` (#8212)

* Fix testing with token

* Add unit test

* Split unit test into 3

* Fix linting error 
tests/test_testing.py