diff options
| author | Tom Christie | 2014-12-15 11:55:17 +0000 | 
|---|---|---|
| committer | Tom Christie | 2014-12-15 11:55:17 +0000 | 
| commit | 72e08a3e8b6427cb93f0f98b42724e31e5b3d8f9 (patch) | |
| tree | 9d2fe5ded957a5e1c6d86ac87aeafb4be3055ab2 /tests | |
| parent | a72f812d80a4000e86a5ad96001f3fbf43fe310a (diff) | |
| download | django-rest-framework-72e08a3e8b6427cb93f0f98b42724e31e5b3d8f9.tar.bz2 | |
Use unicode internally everywhere for 'repr'
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_fields.py | 4 | ||||
| -rw-r--r-- | tests/test_serializer.py | 19 | 
2 files changed, 21 insertions, 2 deletions
| diff --git a/tests/test_fields.py b/tests/test_fields.py index 3f4e65f2..c20bdd8c 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -62,7 +62,7 @@ class TestEmpty:          """          field = serializers.CharField(allow_blank=True)          output = field.run_validation('') -        assert output is '' +        assert output == ''      def test_default(self):          """ @@ -817,7 +817,7 @@ class TestChoiceField(FieldValues):              ]          )          output = field.run_validation('') -        assert output is '' +        assert output == ''  class TestChoiceFieldWithType(FieldValues): diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 56b39095..c17b6d8c 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -1,5 +1,7 @@ +# coding: utf-8  from __future__ import unicode_literals  from rest_framework import serializers +from rest_framework.compat import unicode_repr  import pytest @@ -197,3 +199,20 @@ class TestIncorrectlyConfigured:              "The serializer field might be named incorrectly and not match any attribute or key on the `ExampleObject` instance.\n"              "Original exception text was:"          ) + + +class TestUnicodeRepr: +    def test_unicode_repr(self): +        class ExampleSerializer(serializers.Serializer): +            example = serializers.CharField() + +        class ExampleObject: +            def __init__(self): +                self.example = '한국' + +            def __repr__(self): +                return unicode_repr(self.example) + +        instance = ExampleObject() +        serializer = ExampleSerializer(instance) +        repr(serializer)  # Should not error. | 
