diff options
Diffstat (limited to 'rest_framework/test.py')
| -rw-r--r-- | rest_framework/test.py | 16 | 
1 files changed, 11 insertions, 5 deletions
| diff --git a/rest_framework/test.py b/rest_framework/test.py index df5a5b3b..f89a6dcd 100644 --- a/rest_framework/test.py +++ b/rest_framework/test.py @@ -8,10 +8,11 @@ from django.conf import settings  from django.test.client import Client as DjangoClient  from django.test.client import ClientHandler  from django.test import testcases +from django.utils import six  from django.utils.http import urlencode  from rest_framework.settings import api_settings  from rest_framework.compat import RequestFactory as DjangoRequestFactory -from rest_framework.compat import force_bytes_or_smart_bytes, six +from rest_framework.compat import force_bytes_or_smart_bytes  def force_authenticate(request, user=None, token=None): @@ -36,7 +37,7 @@ class APIRequestFactory(DjangoRequestFactory):          """          if not data: -            return ('', None) +            return ('', content_type)          assert format is None or content_type is None, (              'You may not set both `format` and `content_type`.' @@ -49,9 +50,10 @@ class APIRequestFactory(DjangoRequestFactory):          else:              format = format or self.default_format -            assert format in self.renderer_classes, ("Invalid format '{0}'. " -                "Available formats are {1}.  Set TEST_REQUEST_RENDERER_CLASSES " -                "to enable extra request formats.".format( +            assert format in self.renderer_classes, ( +                "Invalid format '{0}'. Available formats are {1}. " +                "Set TEST_REQUEST_RENDERER_CLASSES to enable " +                "extra request formats.".format(                      format,                      ', '.join(["'" + fmt + "'" for fmt in self.renderer_classes.keys()])                  ) @@ -154,6 +156,10 @@ class APIClient(APIRequestFactory, DjangoClient):          kwargs.update(self._credentials)          return super(APIClient, self).request(**kwargs) +    def logout(self): +        self._credentials = {} +        return super(APIClient, self).logout() +  class APITransactionTestCase(testcases.TransactionTestCase):      client_class = APIClient | 
