@@ -97,16 +97,21 @@ class SB: __call__ = None
9797a 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'
0 commit comments