From 72e08a3e8b6427cb93f0f98b42724e31e5b3d8f9 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 15 Dec 2014 11:55:17 +0000 Subject: Use unicode internally everywhere for 'repr' --- tests/test_serializer.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/test_serializer.py') 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. -- cgit v1.2.3