Show More
@@ -1,3 +1,4 b'' | |||||
|
1 | # coding: utf-8 | |||
1 | """Tests for IPython.lib.pretty.""" |
|
2 | """Tests for IPython.lib.pretty.""" | |
2 |
|
3 | |||
3 | # Copyright (c) IPython Development Team. |
|
4 | # Copyright (c) IPython Development Team. | |
@@ -5,13 +6,11 b'' | |||||
5 |
|
6 | |||
6 | from __future__ import print_function |
|
7 | from __future__ import print_function | |
7 |
|
8 | |||
8 | # Third-party imports |
|
|||
9 | import nose.tools as nt |
|
9 | import nose.tools as nt | |
10 |
|
10 | |||
11 | # Our own imports |
|
|||
12 | from IPython.lib import pretty |
|
11 | from IPython.lib import pretty | |
13 | from IPython.testing.decorators import skip_without |
|
12 | from IPython.testing.decorators import skip_without | |
14 | from IPython.utils.py3compat import PY3 |
|
13 | from IPython.utils.py3compat import PY3, unicode_to_str | |
15 |
|
14 | |||
16 | if PY3: |
|
15 | if PY3: | |
17 | from io import StringIO |
|
16 | from io import StringIO | |
@@ -238,6 +237,21 b' def test_metaclass_repr():' | |||||
238 | nt.assert_equal(output, "[CUSTOM REPR FOR CLASS ClassWithMeta]") |
|
237 | nt.assert_equal(output, "[CUSTOM REPR FOR CLASS ClassWithMeta]") | |
239 |
|
238 | |||
240 |
|
239 | |||
|
240 | def test_unicode_repr(): | |||
|
241 | u = u"üniço∂é" | |||
|
242 | ustr = unicode_to_str(u) | |||
|
243 | ||||
|
244 | class C(object): | |||
|
245 | def __repr__(self): | |||
|
246 | return ustr | |||
|
247 | ||||
|
248 | c = C() | |||
|
249 | p = pretty.pretty(c) | |||
|
250 | nt.assert_equal(p, u) | |||
|
251 | p = pretty.pretty([c]) | |||
|
252 | nt.assert_equal(p, u'[%s]' % u) | |||
|
253 | ||||
|
254 | ||||
241 | def test_basic_class(): |
|
255 | def test_basic_class(): | |
242 | def type_pprint_wrapper(obj, p, cycle): |
|
256 | def type_pprint_wrapper(obj, p, cycle): | |
243 | if obj is MyObj: |
|
257 | if obj is MyObj: |
General Comments 0
You need to be logged in to leave comments.
Login now