From 4080dc66c020aa0ec33845735c9873555a411c37 2015-03-06 23:47:19 From: Min RK Date: 2015-03-06 23:47:19 Subject: [PATCH] test pretty with unicode repr --- diff --git a/IPython/lib/tests/test_pretty.py b/IPython/lib/tests/test_pretty.py index 11f1081..b7738a4 100644 --- a/IPython/lib/tests/test_pretty.py +++ b/IPython/lib/tests/test_pretty.py @@ -1,3 +1,4 @@ +# coding: utf-8 """Tests for IPython.lib.pretty.""" # Copyright (c) IPython Development Team. @@ -5,13 +6,11 @@ from __future__ import print_function -# Third-party imports import nose.tools as nt -# Our own imports from IPython.lib import pretty from IPython.testing.decorators import skip_without -from IPython.utils.py3compat import PY3 +from IPython.utils.py3compat import PY3, unicode_to_str if PY3: from io import StringIO @@ -238,6 +237,21 @@ def test_metaclass_repr(): nt.assert_equal(output, "[CUSTOM REPR FOR CLASS ClassWithMeta]") +def test_unicode_repr(): + u = u"üniço∂é" + ustr = unicode_to_str(u) + + class C(object): + def __repr__(self): + return ustr + + c = C() + p = pretty.pretty(c) + nt.assert_equal(p, u) + p = pretty.pretty([c]) + nt.assert_equal(p, u'[%s]' % u) + + def test_basic_class(): def type_pprint_wrapper(obj, p, cycle): if obj is MyObj: