Skip to content
Next Next commit
Start test case
  • Loading branch information
lovelydinosaur committed Aug 1, 2016
commit 08c7853655252cb9de0ade24eddfc9762a01cee7
5 changes: 5 additions & 0 deletions rest_framework/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.utils import six
from django.utils.encoding import force_bytes
from django.utils.http import urlencode
from requests import Session

from rest_framework.settings import api_settings

Expand Down Expand Up @@ -221,6 +222,10 @@ class APITransactionTestCase(testcases.TransactionTestCase):
class APITestCase(testcases.TestCase):
client_class = APIClient

def _pre_setup(self):
super(APITestCase, self)._pre_setup()
self.requests = Session()


class APISimpleTestCase(testcases.SimpleTestCase):
client_class = APIClient
Expand Down
24 changes: 24 additions & 0 deletions tests/test_requests_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import unicode_literals

from django.conf.urls import url
from django.test import override_settings

from rest_framework.response import Response
from rest_framework.test import APITestCase
from rest_framework.views import APIView


class Root(APIView):
def get(self, request):
return Response({'hello': 'world'})


urlpatterns = [
url(r'^$', Root.as_view()),
]


@override_settings(ROOT_URLCONF='tests.test_requests_client')
class RequestsClientTests(APITestCase):
def test_get_root(self):
print self.requests.get('http://example.com')