mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-27 03:54:01 +03:00
Fix the tests on 1.3 and HEAD
In the latest Django master code, RequestFactory.put behaves fundamentally differently than it did pre-1.5. By default, it expects an octet string as opposed to a dictionary that it will encode like a multipart form. So, for 1.5 and on, we have to be explicit about the multipart type and pre-encode the data. However, pre-1.5 Django expects a dictionary if the content type is multipart. So, the cleanest thing to do is explicitly handle the versions independently.
This commit is contained in:
parent
f729d0eb0b
commit
9c007a6197
|
@ -4,7 +4,6 @@ Tests for content parsing, and form-overloaded content parsing.
|
|||
from django.conf.urls.defaults import patterns
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase, Client
|
||||
from django.test.client import MULTIPART_CONTENT, BOUNDARY, encode_multipart
|
||||
|
||||
from djangorestframework import status
|
||||
from djangorestframework.authentication import SessionAuthentication
|
||||
|
@ -95,8 +94,16 @@ class TestContentParsing(TestCase):
|
|||
"""
|
||||
data = {'qwerty': 'uiop'}
|
||||
parsers = (FormParser, MultiPartParser)
|
||||
request = factory.put('/', encode_multipart(BOUNDARY, data), parsers=parsers,
|
||||
content_type=MULTIPART_CONTENT)
|
||||
|
||||
from django import VERSION
|
||||
|
||||
if VERSION >= (1, 5):
|
||||
from django.test.client import MULTIPART_CONTENT, BOUNDARY, encode_multipart
|
||||
request = factory.put('/', encode_multipart(BOUNDARY, data), parsers=parsers,
|
||||
content_type=MULTIPART_CONTENT)
|
||||
else:
|
||||
request = factory.put('/', data, parsers=parsers)
|
||||
|
||||
self.assertEqual(request.DATA.items(), data.items())
|
||||
|
||||
def test_standard_behaviour_determines_non_form_content_PUT(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user