Skip to content

Commit 97a2ec8

Browse files
committed
react to feedback
1 parent df3f367 commit 97a2ec8

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

Doc/library/textwrap.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ hyphenated words; only then will long words be broken if necessary, unless
286286
(default: ``len``) Used to determine the length of a string. You can
287287
provide a custom function, e.g. to account for wide characters.
288288

289+
.. versionadded:: 3.11
290+
289291

290292
.. index:: single: ...; placeholder
291293

Lib/test/test_textwrap.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,22 +1078,19 @@ def test_first_word_too_long_but_placeholder_fits(self):
10781078

10791079

10801080
class WideCharacterTestCase(BaseTestCase):
1081-
def setUp(self):
1081+
def test_wide_character(self):
10821082
def text_len(text):
10831083
n = 0
10841084
for c in text:
1085-
if unicodedata.east_asian_width(c) in ['F', 'W']:
1085+
if unicodedata.east_asian_width(c) in {'F', 'W'}:
10861086
n += 2
10871087
else:
10881088
n += 1
10891089
return n
10901090

1091-
self.wrapper = TextWrapper(width=5, text_len=text_len)
1092-
1093-
def test_wide_character(self):
10941091
text = "123 🔧"
1095-
result = self.wrapper.wrap(text, **kwargs)
1096-
self.check(result, ["123", "🔧"])
1092+
expected = ["123", "🔧"]
1093+
self.check_wrap(text, 6, expected, text_len=text_len)
10971094

10981095

10991096
if __name__ == '__main__':

Lib/textwrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ def _wrap_chunks(self, chunks):
261261
indent = self.subsequent_indent
262262
else:
263263
indent = self.initial_indent
264-
if self.text_len(indent) +
265-
self.text_len(self.placeholder.lstrip()) > self.width:
264+
if (self.text_len(indent) +
265+
self.text_len(self.placeholder.lstrip()) > self.width):
266266
raise ValueError("placeholder too large for max width")
267267

268268
# Arrange in reverse order so items can be efficiently popped

0 commit comments

Comments
 (0)