mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-08 11:14:24 +03:00
Import force_bytes on django >= 1.5
This commit is contained in:
parent
0383f11ff7
commit
74fec7eeb4
|
@ -457,7 +457,7 @@ from django.test.client import RequestFactory as DjangoRequestFactory
|
|||
from django.test.client import FakePayload
|
||||
try:
|
||||
# In 1.5 the test client uses force_bytes
|
||||
from django.utils.encoding import force_bytes_or_smart_bytes
|
||||
from django.utils.encoding import force_bytes as force_bytes_or_smart_bytes
|
||||
except ImportError:
|
||||
# In 1.3 and 1.4 the test client just uses smart_str
|
||||
from django.utils.encoding import smart_str as force_bytes_or_smart_bytes
|
||||
|
|
13
rest_framework/tests/test_compat.py
Normal file
13
rest_framework/tests/test_compat.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
import django
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class TestCompat(TestCase):
|
||||
def test_force_bytes_or_smart_bytes(self):
|
||||
from rest_framework.compat import force_bytes_or_smart_bytes
|
||||
if django.VERSION >= (1, 5):
|
||||
from django.utils.encoding import force_bytes
|
||||
self.assertEqual(force_bytes_or_smart_bytes, force_bytes)
|
||||
else:
|
||||
from django.utils.encoding import smart_str
|
||||
self.assertEqual(force_bytes_or_smart_bytes, smart_str)
|
Loading…
Reference in New Issue
Block a user