Skip to content

Commit 3fc3894

Browse files
committed
Revert some tese cases
1 parent 752344a commit 3fc3894

File tree

2 files changed

+49
-17
lines changed

2 files changed

+49
-17
lines changed

Lib/idlelib/idle_test/test_calltip.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,21 @@ class SB: __call__ = None
9797
a replacement string to be used.''')
9898
tiptest(p.sub, '''\
9999
(repl, string, count=0)
100-
Return the string obtained by replacing the leftmost non-overlapping \
101-
occurrences of pattern in string by the replacement repl.''')
100+
Return the string obtained by replacing the leftmost \
101+
non-overlapping occurrences of pattern in string by the replacement repl.''')
102102

103-
def test_signature(self):
103+
def test_signature_wrap(self):
104104
if textwrap.TextWrapper.__doc__ is not None:
105-
self.assertEqual(get_spec(textwrap.TextWrapper).split('\n')[0], '''\
105+
self.assertEqual(get_spec(textwrap.TextWrapper).split('\n\n')[0], '''\
106106
(width=70, initial_indent='', subsequent_indent='', expand_tabs=True, \
107107
replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, \
108108
drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, \
109-
placeholder=' [...]')''')
109+
placeholder=' [...]')
110+
Object for wrapping/filling text. The public interface consists of
111+
the wrap() and fill() methods; the other methods are just there for
112+
subclasses to override in order to tweak the default behaviour.
113+
If you want to completely replace the main wrapping algorithm,
114+
you\'ll probably have to override _wrap_chunks().''')
110115

111116
def test_properly_formatted(self):
112117

@@ -120,8 +125,6 @@ def bar(s='a'*100):
120125
def baz(s='a'*100, z='b'*100):
121126
pass
122127

123-
indent = calltip._INDENT
124-
125128
sfoo = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
126129
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"
127130
sbar = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
@@ -139,7 +142,41 @@ def baz(s='a'*100, z='b'*100):
139142
def test_docline_truncation(self):
140143
def f(): pass
141144
f.__doc__ = 'a'*300
142-
self.assertEqual(get_spec(f), "()\n%s" % ('a'*300))
145+
self.assertEqual(get_spec(f), f"()\n{f.__doc__}")
146+
147+
@unittest.skipIf(MISSING_C_DOCSTRINGS,
148+
"Signature information for builtins requires docstrings")
149+
def test_multiline_docstring(self):
150+
# Test fewer lines than max.
151+
self.assertEqual(get_spec(range), '''\
152+
range(stop) -> range object
153+
range(start, stop[, step]) -> range object
154+
155+
Return an object that produces a sequence of integers from start (inclusive)
156+
to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.
157+
start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.
158+
These are exactly the valid indices for a list of 4 elements.
159+
When step is given, it specifies the increment (or decrement).''')
160+
161+
# Test max lines
162+
self.assertEqual(get_spec(bytes), '''\
163+
bytes(iterable_of_ints) -> bytes
164+
bytes(string, encoding[, errors]) -> bytes
165+
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
166+
bytes(int) -> bytes object of size given by the parameter initialized with null bytes
167+
bytes() -> empty bytes object
168+
169+
Construct an immutable array of bytes from:
170+
- an iterable yielding integers in range(256)
171+
- a text string encoded using the specified encoding
172+
- any object implementing the buffer API.
173+
- an integer''')
174+
175+
def test_multiline_docstring_2(self):
176+
# Test more than max lines
177+
def f(): pass
178+
f.__doc__ = 'a\n' * 15
179+
self.assertEqual(get_spec(f), '()\n' + f.__doc__[:-1])
143180

144181
def test_functions(self):
145182
def t1(): 'doc'
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
Make CallTips selectable
22

3-
The text display widget in the "CalltipWindow" has been changed from
4-
"tk.Label" to "ScrolledText", and now the text in the "Calltip" window can
5-
be selected with mouse. The display size of the "CalltipWindow" is set to
6-
the smaller value between the size when using the "tk.Label" widget and the
7-
default size of "tk.Text". When the displayed text exceeds the display area
8-
of the "ScrolledText" window, showing the vertical scrollbar; otherwise,
9-
hiding the scrollbar. Since more text can be displayed, "argspec" is no
10-
longer truncated, and the tests related to the max lines or text truncation
11-
have been removed from the unit tests. Contributed by Shixian Li.
3+
Use the "ScrolledText" widget instead of "tk.Label" to display the tooltips,
4+
and now the text in the "Calltip" window can be selected with mouse, or
5+
scrolled by mouse wheel. Docstring is no longer need to truncated, so some
6+
test cases have been changed. Contributed by Shixian Li.

0 commit comments

Comments
 (0)