summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-01-22 01:45:17 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2014-01-22 01:45:17 (GMT)
commitd5710f8b36a456872f3cadd913a26f4aa76afc01 (patch)
tree9f4f26361dc1e1d50ecae03a2642d5f69993a02e /Lib/idlelib/idle_test
parent758fa5ea819d4301afed5049fa1186f275c4f801 (diff)
downloadcpython-d5710f8b36a456872f3cadd913a26f4aa76afc01.zip
cpython-d5710f8b36a456872f3cadd913a26f4aa76afc01.tar.gz
cpython-d5710f8b36a456872f3cadd913a26f4aa76afc01.tar.bz2
Issue #16638: Include up to 5 docstring header lines (before first blank) in
Idle calltips. This is needed for builtins, such bytes (which is why 5). Based on patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_calltips.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/Lib/idlelib/idle_test/test_calltips.py b/Lib/idlelib/idle_test/test_calltips.py
index 18cc35c..eca24ec 100644
--- a/Lib/idlelib/idle_test/test_calltips.py
+++ b/Lib/idlelib/idle_test/test_calltips.py
@@ -42,17 +42,15 @@ class Get_signatureTest(unittest.TestCase):
# For a simple mismatch, change the expected output to the actual.
def test_builtins(self):
- # These test will break if
# Python class that inherits builtin methods
class List(list): "List() doc"
- # Simulate builtin with no docstring for default argspec test
+ # Simulate builtin with no docstring for default tip test
class SB: __call__ = None
def gtest(obj, out):
self.assertEqual(signature(obj), out)
- gtest(list, "list() -> new empty list")
gtest(List, List.__doc__)
gtest(list.__new__,
'T.__new__(S, ...) -> a new object with type S, a subtype of T')
@@ -66,6 +64,21 @@ class Get_signatureTest(unittest.TestCase):
gtest(types.MethodType, "method(function, instance)")
gtest(SB(), default_tip)
+ def test_multiline_docstring(self):
+ # Test fewer lines than max.
+ self.assertEqual(signature(list),
+ "list() -> new empty list\n"
+ "list(iterable) -> new list initialized from iterable's items")
+
+ # Test max lines and line (currently) too long.
+ self.assertEqual(signature(bytes),
+"bytes(iterable_of_ints) -> bytes\n"
+"bytes(string, encoding[, errors]) -> bytes\n"
+"bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer\n"
+#bytes(int) -> bytes object of size given by the parameter initialized with null bytes
+"bytes(int) -> bytes object of size given by the parameter initialized with n...\n"
+"bytes() -> empty bytes object")
+
def test_functions(self):
def t1(): 'doc'
t1.tip = "()"
@@ -100,7 +113,8 @@ class Get_signatureTest(unittest.TestCase):
assert ct._first_param.sub('', uni) == '(a)'
def test_no_docstring(self):
- def nd(s): pass
+ def nd(s):
+ pass
TC.nd = nd
self.assertEqual(signature(nd), "(s)")
self.assertEqual(signature(TC.nd), "(s)")