Show More
@@ -662,7 +662,8 b' class Inspector:' | |||
|
662 | 662 | # from its __call__ method. |
|
663 | 663 | |
|
664 | 664 | if inspect.isclass(obj): |
|
665 | callable_obj = obj.__init__ | |
|
665 | # Old-style classes need not have an __init__ | |
|
666 | callable_obj = getattr(obj, "__init__", None) | |
|
666 | 667 | elif callable(obj): |
|
667 | 668 | callable_obj = obj |
|
668 | 669 | else: |
@@ -45,6 +45,10 b' class Call(object):' | |||
|
45 | 45 | def method(self, x, z=2): |
|
46 | 46 | """Some method's docstring""" |
|
47 | 47 | |
|
48 | class OldStyle: | |
|
49 | """An old-style class for testing.""" | |
|
50 | pass | |
|
51 | ||
|
48 | 52 | def f(x, y=2, *a, **kw): |
|
49 | 53 | """A simple function.""" |
|
50 | 54 | |
@@ -117,3 +121,11 b' def test_info():' | |||
|
117 | 121 | nt.assert_equal(i['class_docstring'], Call.__doc__) |
|
118 | 122 | nt.assert_equal(i['init_docstring'], Call.__init__.__doc__) |
|
119 | 123 | nt.assert_equal(i['call_docstring'], c.__call__.__doc__) |
|
124 | ||
|
125 | # Test old-style classes, which for example may not have an __init__ method. | |
|
126 | i = inspector.info(OldStyle) | |
|
127 | nt.assert_equal(i['type_name'], 'classobj') | |
|
128 | ||
|
129 | i = inspector.info(OldStyle()) | |
|
130 | nt.assert_equal(i['type_name'], 'instance') | |
|
131 | nt.assert_equal(i['docstring'], OldStyle.__doc__) |
General Comments 0
You need to be logged in to leave comments.
Login now