##// END OF EJS Templates
Merge pull request #9617 from minrk/list-signature...
Thomas Kluyver -
r22540:5b668f24 merge
parent child Browse files
Show More
@@ -848,20 +848,27 b' class Inspector(Colorable):'
848 848 except AttributeError:
849 849 init_def = None
850 850
851 if init_def:
852 out['init_definition'] = init_def
853
854 851 # get the __init__ docstring
855 852 try:
856 853 obj_init = obj.__init__
857 854 except AttributeError:
858 855 init_ds = None
859 856 else:
857 if init_def is None:
858 # Get signature from init if top-level sig failed.
859 # Can happen for built-in types (list, etc.).
860 try:
861 init_def = self._getdef(obj_init, oname)
862 except AttributeError:
863 pass
860 864 init_ds = getdoc(obj_init)
861 865 # Skip Python's auto-generated docstrings
862 866 if init_ds == _object_init_docstring:
863 867 init_ds = None
864 868
869 if init_def:
870 out['init_definition'] = init_def
871
865 872 if init_ds:
866 873 out['init_docstring'] = init_ds
867 874
@@ -419,15 +419,34 b' def test_pdef():'
419 419 def foo(): pass
420 420 inspector.pdef(foo, 'foo')
421 421
422
422 423 def test_pinfo_nonascii():
423 424 # See gh-1177
424 425 from . import nonascii2
425 426 ip.user_ns['nonascii2'] = nonascii2
426 427 ip._inspect('pinfo', 'nonascii2', detail_level=1)
427 428
429
428 430 def test_pinfo_magic():
429 431 with AssertPrints('Docstring:'):
430 432 ip._inspect('pinfo', 'lsmagic', detail_level=0)
431 433
432 434 with AssertPrints('Source:'):
433 435 ip._inspect('pinfo', 'lsmagic', detail_level=1)
436
437
438 def test_init_colors():
439 # ensure colors are not present in signature info
440 info = inspector.info(HasSignature)
441 init_def = info['init_definition']
442 nt.assert_not_in('[0m', init_def)
443
444
445 def test_builtin_init():
446 info = inspector.info(list)
447 init_def = info['init_definition']
448 # Python < 3.4 can't get init definition from builtins,
449 # but still exercise the inspection in case of error-raising bugs.
450 if sys.version_info >= (3,4):
451 nt.assert_is_not_none(init_def)
452
General Comments 0
You need to be logged in to leave comments. Login now