          auth = "Token " + token.key
          client = Client(enforce_csrf_checks=True)
          response = client.post('/auth-token/logout/', HTTP_AUTHORIZATION=auth)
          self.assertEqual(response.status_code, 200)
          # Ensure token no longer exists
          self.assertRaises(Token.DoesNotExist, lambda token: Token.objects.get(key=token.key), token)
 
</s> remove                                     {'username': self.username, 'password': self.password})
        self.assertEqual(response.status_code, 201)
        self.assertEqual(json.loads(response.content)['token'], self.key)

    def test_token_logout(self):
        """Ensure token logout view using JSON POST works."""
        # Use different User and Token as to isolate this test's effects on other unittests in class
        username = "ringo"
        user = User.objects.create_user(username, "starr@thebeatles.com", "pass")
        token = Token.objects.create(user=user)
        auth = "Token " + token.key
        client = Client(enforce_csrf_checks=True)
        response = client.post('/auth-token/logout/', HTTP_AUTHORIZATION=auth)
 </s> add                                {'username': self.username, 'password': self.password}) </s> remove                                     json.dumps({'username': self.username, 'password': self.password}), 'application/json')
        self.assertEqual(response.status_code, 201)
 </s> add                                json.dumps({'username': self.username, 'password': self.password}), 'application/json')
        self.assertEqual(response.status_code, 200) </s> remove                                     json.dumps({'username': self.username}), 'application/json')
 </s> add                                json.dumps({'username': self.username}), 'application/json') </s> remove                                     json.dumps({'username': self.username, 'password': "badpass"}), 'application/json')
 </s> add                                json.dumps({'username': self.username, 'password': "badpass"}), 'application/json') </s> remove     token = serializers.Field(source="key")
    username = serializers.CharField(max_length=30)
 </s> add     username = serializers.CharField()
        self.assertEqual(json.loads(response.content)['token'], self.key)
          auth = "Token " + token.key
          client = Client(enforce_csrf_checks=True)
          response = client.post('/auth-token/logout/', HTTP_AUTHORIZATION=auth)
          self.assertEqual(response.status_code, 200)
        self.assertEqual(json.loads(response.content)['token'], self.key)
        self.assertEqual(json.loads(response.content)['token'], self.key)
keep keep keep keep replace replace
 Updates to login view for TokenAuthentication from feedback from Tom 
rest_framework/tests/authentication.py