Show More
@@ -647,7 +647,7 b' class Inspector(Colorable):' | |||
|
647 | 647 | # Functions, methods, classes |
|
648 | 648 | append_field(_mime, 'Signature', 'definition', code_formatter) |
|
649 | 649 | append_field(_mime, 'Init signature', 'init_definition', code_formatter) |
|
650 | if detail_level > 0: | |
|
650 | if detail_level > 0 and info['source']: | |
|
651 | 651 | append_field(_mime, 'Source', 'source', code_formatter) |
|
652 | 652 | else: |
|
653 | 653 | append_field(_mime, 'Docstring', 'docstring', formatter) |
@@ -19,7 +19,7 b' from IPython.core.magic import (Magics, magics_class, line_magic,' | |||
|
19 | 19 | register_line_cell_magic) |
|
20 | 20 | from decorator import decorator |
|
21 | 21 | from IPython.testing.decorators import skipif |
|
22 | from IPython.testing.tools import AssertPrints | |
|
22 | from IPython.testing.tools import AssertPrints, AssertNotPrints | |
|
23 | 23 | from IPython.utils.path import compress_user |
|
24 | 24 | from IPython.utils import py3compat |
|
25 | 25 | from IPython.utils.signatures import Signature, Parameter |
@@ -404,12 +404,12 b' def test_property_docstring_is_in_info_for_detail_level_0():' | |||
|
404 | 404 | pass |
|
405 | 405 | |
|
406 | 406 | ip.user_ns['a_obj'] = A() |
|
407 |
nt.assert_equal |
|
|
407 | nt.assert_equal( | |
|
408 | 408 | 'This is `foobar` property.', |
|
409 | 409 | ip.object_inspect('a_obj.foobar', detail_level=0)['docstring']) |
|
410 | 410 | |
|
411 | 411 | ip.user_ns['a_cls'] = A |
|
412 |
nt.assert_equal |
|
|
412 | nt.assert_equal( | |
|
413 | 413 | 'This is `foobar` property.', |
|
414 | 414 | ip.object_inspect('a_cls.foobar', detail_level=0)['docstring']) |
|
415 | 415 | |
@@ -427,6 +427,29 b' def test_pinfo_nonascii():' | |||
|
427 | 427 | ip._inspect('pinfo', 'nonascii2', detail_level=1) |
|
428 | 428 | |
|
429 | 429 | |
|
430 | def test_pinfo_docstring_no_source(): | |
|
431 | """Docstring should be included with detail_level=1 if there is no source""" | |
|
432 | with AssertPrints('Docstring:'): | |
|
433 | ip._inspect('pinfo', 'str.format', detail_level=0) | |
|
434 | with AssertPrints('Docstring:'): | |
|
435 | ip._inspect('pinfo', 'str.format', detail_level=1) | |
|
436 | ||
|
437 | ||
|
438 | def test_pinfo_no_docstring_if_source(): | |
|
439 | """Docstring should not be included with detail_level=1 if source is found""" | |
|
440 | def foo(): | |
|
441 | """foo has a docstring""" | |
|
442 | ||
|
443 | ip.user_ns['foo'] = foo | |
|
444 | ||
|
445 | with AssertPrints('Docstring:'): | |
|
446 | ip._inspect('pinfo', 'foo', detail_level=0) | |
|
447 | with AssertPrints('Source:'): | |
|
448 | ip._inspect('pinfo', 'foo', detail_level=1) | |
|
449 | with AssertNotPrints('Docstring:'): | |
|
450 | ip._inspect('pinfo', 'foo', detail_level=1) | |
|
451 | ||
|
452 | ||
|
430 | 453 | def test_pinfo_magic(): |
|
431 | 454 | with AssertPrints('Docstring:'): |
|
432 | 455 | ip._inspect('pinfo', 'lsmagic', detail_level=0) |
General Comments 0
You need to be logged in to leave comments.
Login now