Skip to content

Commit

Permalink
Merge pull request #5003 from takluyver/thats-pretty-super
Browse files Browse the repository at this point in the history
Fix pretty reprs of super() objects
  • Loading branch information
ellisonbg committed Feb 4, 2014
2 parents 6acbd12 + 98b2968 commit f98dd14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IPython/lib/pretty.py
Expand Up @@ -678,7 +678,7 @@ def inner(obj, p, cycle):
def _super_pprint(obj, p, cycle):
"""The pprint for the super type."""
p.begin_group(8, '<super: ')
p.pretty(obj.__self_class__)
p.pretty(obj.__thisclass__)
p.text(',')
p.breakable()
p.pretty(obj.__self__)
Expand Down
15 changes: 15 additions & 0 deletions IPython/lib/tests/test_pretty.py
Expand Up @@ -181,4 +181,19 @@ def test_really_bad_repr():
nt.assert_in("failed", output)
nt.assert_in("BadException: unknown", output)
nt.assert_in("unknown type", output)


class SA(object):
pass

class SB(SA):
pass

def test_super_repr():
output = pretty.pretty(super(SA))
nt.assert_in("SA", output)

sb = SB()
output = pretty.pretty(super(SA, sb))
nt.assert_in("SA", output)

0 comments on commit f98dd14

Please sign in to comment.