Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Jan 22, 2022
1 parent fff337f commit e7f4477
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gapic/utils/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def wrap(text: str, width: int, *, offset: int = None, indent: int = 0) -> str:
# Break off the first line of the string to address non-zero offsets.
first = text.split('\n')[0] + '\n'
if len(first) > width - offset:
# Ensure `break_on_hyphens` is set to `False` when using
# `textwrap.wrap` to avoid breaking hyperlinks with hyphens.
initial = textwrap.wrap(first,
break_long_words=False,
width=width - offset,
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/utils/test_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ def test_wrap_indent_short():

def test_wrap_short_line_preserved():
assert lines.wrap('foo\nbar\nbaz', width=80) == 'foo\nbar\nbaz'

def test_wrap_does_not_break_hyphenated_word():
assert lines.wrap('do-not-break', width=5) == 'do-not-break'

0 comments on commit e7f4477

Please sign in to comment.