bpo-35641: IDLE - format calltip properly when no docstring (GH-11415)

This commit is contained in:
Emmanuel Arias 2019-01-03 04:47:58 -03:00 committed by Terry Jan Reedy
parent aff0adabf3
commit ab54b9a130
4 changed files with 32 additions and 1 deletions

View File

@ -167,7 +167,7 @@ def get_argspec(ob):
if len(line) > _MAX_COLS:
line = line[: _MAX_COLS - 3] + '...'
lines.append(line)
argspec = '\n'.join(lines)
argspec = '\n'.join(lines)
if not argspec:
argspec = _default_callable_argspec
return argspec

View File

@ -99,6 +99,35 @@ def test_signature_wrap(self):
drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None,
placeholder=' [...]')''')
def test_properly_formated(self):
def foo(s='a'*100):
pass
def bar(s='a'*100):
"""Hello Guido"""
pass
def baz(s='a'*100, z='b'*100):
pass
indent = calltip._INDENT
str_foo = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\
"aaaaaaaaaa')"
str_bar = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\
"aaaaaaaaaa')\nHello Guido"
str_baz = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\
"aaaaaaaaaa', z='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"\
"bbbbbbbbbbbbbbbbb\n" + indent + "bbbbbbbbbbbbbbbbbbbbbb"\
"bbbbbbbbbbbbbbbbbbbbbb')"
self.assertEqual(calltip.get_argspec(foo), str_foo)
self.assertEqual(calltip.get_argspec(bar), str_bar)
self.assertEqual(calltip.get_argspec(baz), str_baz)
def test_docline_truncation(self):
def f(): pass
f.__doc__ = 'a'*300

View File

@ -60,6 +60,7 @@ Heidi Annexstad
Ramchandra Apte
Éric Araujo
Alexandru Ardelean
Emmanuel Arias
Alicia Arlen
Jeffrey Armstrong
Jason Asbahr

View File

@ -0,0 +1 @@
Proper format `calltip` when the function has no docstring.