Commit 74fec7ee by Ian Foote

Import force_bytes on django >= 1.5

parent 0383f11f
......@@ -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
......
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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment