Commit 9923a6ce by Tom Christie

Fix tests for py2/3 compat

parent a919068c
...@@ -3,6 +3,7 @@ Tests to cover bulk create and update using serializers. ...@@ -3,6 +3,7 @@ Tests to cover bulk create and update using serializers.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
from django.test import TestCase from django.test import TestCase
from django.utils import six
from rest_framework import serializers from rest_framework import serializers
...@@ -82,10 +83,12 @@ class BulkCreateSerializerTests(TestCase): ...@@ -82,10 +83,12 @@ class BulkCreateSerializerTests(TestCase):
serializer = self.BookSerializer(data=data, many=True) serializer = self.BookSerializer(data=data, many=True)
self.assertEqual(serializer.is_valid(), False) self.assertEqual(serializer.is_valid(), False)
text_type_string = six.text_type.__name__
message = 'Invalid data. Expected a dictionary, but got %s.' % text_type_string
expected_errors = [ expected_errors = [
{'non_field_errors': ['Invalid data. Expected a dictionary, but got unicode.']}, {'non_field_errors': [message]},
{'non_field_errors': ['Invalid data. Expected a dictionary, but got unicode.']}, {'non_field_errors': [message]},
{'non_field_errors': ['Invalid data. Expected a dictionary, but got unicode.']} {'non_field_errors': [message]}
] ]
self.assertEqual(serializer.errors, expected_errors) self.assertEqual(serializer.errors, expected_errors)
......
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