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