mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Start test case
This commit is contained in:
parent
48a2f084aa
commit
08c7853655
|
@ -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
|
||||
|
|
24
tests/test_requests_client.py
Normal file
24
tests/test_requests_client.py
Normal 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')
|
Loading…
Reference in New Issue
Block a user