Skip to content

Commit

Permalink
Add test for display_width function
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreg committed Feb 15, 2023
1 parent 3585d75 commit 6897a37
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,25 @@ def test_write_section_print_long_constraint_on_a_new_line():
formatter.write_section(section)
actual = formatter.getvalue()
assert actual == expected


def test_display_width():
rows = [
# `✔️` char has length of 2 but display width of 1
('-l, --long-option-name TEXT✔️', LOREM),
('--another-option INT', LOREM),
('--short', LOREM),
]

formatter = HelpFormatter(width=80)
formatter.current_indent = 4
expected = """
-l, --long-option-name TEXT✔️ Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor.
--another-option INT Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor.
--short Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor.
"""[1:-4]
formatter.write_dl(rows)
assert formatter.getvalue() == expected

0 comments on commit 6897a37

Please sign in to comment.