Show More
@@ -602,10 +602,16 b' def _re_pattern_pprint(obj, p, cycle):' | |||||
602 |
|
602 | |||
603 | def _type_pprint(obj, p, cycle): |
|
603 | def _type_pprint(obj, p, cycle): | |
604 | """The pprint for classes and types.""" |
|
604 | """The pprint for classes and types.""" | |
605 | if obj.__module__ in ('__builtin__', 'exceptions'): |
|
605 | try: | |
|
606 | mod = obj.__module__ | |||
|
607 | except AttributeError: | |||
|
608 | # Heap allocated types might not have the module attribute. | |||
|
609 | return p.text(obj.__name__) | |||
|
610 | ||||
|
611 | if mod in ('__builtin__', 'exceptions'): | |||
606 | name = obj.__name__ |
|
612 | name = obj.__name__ | |
607 | else: |
|
613 | else: | |
608 |
name = |
|
614 | name = mod + '.' + obj.__name__ | |
609 | p.text(name) |
|
615 | p.text(name) | |
610 |
|
616 | |||
611 |
|
617 |
@@ -18,6 +18,7 b' import nose.tools as nt' | |||||
18 |
|
18 | |||
19 | # Our own imports |
|
19 | # Our own imports | |
20 | from IPython.lib import pretty |
|
20 | from IPython.lib import pretty | |
|
21 | from IPython.testing.decorators import skip_without | |||
21 |
|
22 | |||
22 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
23 | # Classes and functions |
|
24 | # Classes and functions | |
@@ -63,3 +64,12 b' def test_dispatch():' | |||||
63 | expectedoutput = "MyDict(...)" |
|
64 | expectedoutput = "MyDict(...)" | |
64 |
|
65 | |||
65 | nt.assert_equals(gotoutput, expectedoutput) |
|
66 | nt.assert_equals(gotoutput, expectedoutput) | |
|
67 | ||||
|
68 | @skip_without('xxlimited') | |||
|
69 | def test_pprint_heap_allocated_type(): | |||
|
70 | """ | |||
|
71 | Test that pprint works for heap allocated types. | |||
|
72 | """ | |||
|
73 | import xxlimited | |||
|
74 | output = pretty.pretty(xxlimited.Null) | |||
|
75 | nt.assert_equal(output, 'xxlimited.Null') |
General Comments 0
You need to be logged in to leave comments.
Login now