Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit e7f4477

Browse files
committed
add test
1 parent fff337f commit e7f4477

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

gapic/utils/lines.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def wrap(text: str, width: int, *, offset: int = None, indent: int = 0) -> str:
7878
# Break off the first line of the string to address non-zero offsets.
7979
first = text.split('\n')[0] + '\n'
8080
if len(first) > width - offset:
81+
# Ensure `break_on_hyphens` is set to `False` when using
82+
# `textwrap.wrap` to avoid breaking hyperlinks with hyphens.
8183
initial = textwrap.wrap(first,
8284
break_long_words=False,
8385
width=width - offset,

tests/unit/utils/test_lines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,6 @@ def test_wrap_indent_short():
8787

8888
def test_wrap_short_line_preserved():
8989
assert lines.wrap('foo\nbar\nbaz', width=80) == 'foo\nbar\nbaz'
90+
91+
def test_wrap_does_not_break_hyphenated_word():
92+
assert lines.wrap('do-not-break', width=5) == 'do-not-break'

0 commit comments

Comments
 (0)