From 08c7853655252cb9de0ade24eddfc9762a01cee7 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 1 Aug 2016 14:15:35 +0100 Subject: [PATCH] Start test case --- rest_framework/test.py | 5 +++++ tests/test_requests_client.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/test_requests_client.py diff --git a/rest_framework/test.py b/rest_framework/test.py index 3ba4059a9..fb08c4a73 100644 --- a/rest_framework/test.py +++ b/rest_framework/test.py @@ -12,6 +12,7 @@ from django.test.client import ClientHandler 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 @@ -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 diff --git a/tests/test_requests_client.py b/tests/test_requests_client.py new file mode 100644 index 000000000..a36349a3f --- /dev/null +++ b/tests/test_requests_client.py @@ -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')