Start test case

This commit is contained in:
Tom Christie 2016-08-01 14:15:35 +01:00
parent 48a2f084aa
commit 08c7853655
2 changed files with 29 additions and 0 deletions

View File

@ -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

View File

@ -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')