aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_serializer.py
diff options
context:
space:
mode:
authorTom Christie2014-12-15 12:04:46 +0000
committerTom Christie2014-12-15 12:04:46 +0000
commitaf53e34dd5873f3373e9991c3825e70d92432e14 (patch)
treef5503776ef204ff125f476116b11ca0801fd3b8e /tests/test_serializer.py
parent1f6fd924fea05b9b7eb4bedf44dfdcb2f14c5cad (diff)
parentdc66cce16da6793efe4a4a4dcdd18db62c859abb (diff)
downloaddjango-rest-framework-af53e34dd5873f3373e9991c3825e70d92432e14.tar.bz2
Merge pull request #2279 from tomchristie/fix-serializer-repr-unicode-bug
Use unicode internally everywhere for 'repr'.
Diffstat (limited to 'tests/test_serializer.py')
-rw-r--r--tests/test_serializer.py19
1 files changed, 19 insertions, 0 deletions
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.