From 8318fbe0932369b04e6b30a01a2cc5bd20922b6a 2014-10-17 20:29:21 From: Remi Rampin Date: 2014-10-17 20:29:21 Subject: [PATCH] Adds test for pprinting type with meta __repr__ Tests that pretty-printing a type calls the metaclass's __repr__, if it exists. --- diff --git a/IPython/lib/tests/test_pretty.py b/IPython/lib/tests/test_pretty.py index b63197f..de9410c 100644 --- a/IPython/lib/tests/test_pretty.py +++ b/IPython/lib/tests/test_pretty.py @@ -213,4 +213,20 @@ def test_long_dict(): def test_unbound_method(): output = pretty.pretty(MyObj.somemethod) - nt.assert_in('MyObj.somemethod', output) \ No newline at end of file + nt.assert_in('MyObj.somemethod', output) + + +class MetaClass(type): + def __new__(cls, name): + return type.__new__(cls, name, (object,), {'name': name}) + + def __repr__(self): + return "[CUSTOM REPR FOR CLASS %s]" % self.name + + +ClassWithMeta = MetaClass('ClassWithMeta') + + +def test_metaclass_repr(): + output = pretty.pretty(ClassWithMeta) + nt.assert_equal(output, "[CUSTOM REPR FOR CLASS ClassWithMeta]")