summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-12-09 16:34:07 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-12-09 16:34:07 -0500
commit5ffed1387ddc4e5725f9c6b5b632a611eca1e3ca (patch)
treea9092d195e5099c62e526adfbf46acc77ef3b84b /tests/test_utils.py
parent6f16e671971a9fac4edfda9c0117ceaeb5e6487e (diff)
downloadcmd2-git-5ffed1387ddc4e5725f9c6b5b632a611eca1e3ca.tar.gz
Added more text alignment unit tests
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 1327064f..745e5ff4 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -326,7 +326,7 @@ def test_align_text_blank():
fill_char = '-'
width = 5
aligned = cu.align_text(text, fill_char=fill_char, width=width, alignment=cu.TextAlignment.LEFT)
- assert aligned == text + fill_char * width
+ assert aligned == fill_char * width
def test_align_text_wider_than_width():
text = 'long'
@@ -335,6 +335,13 @@ def test_align_text_wider_than_width():
aligned = cu.align_text(text, fill_char=fill_char, width=width, alignment=cu.TextAlignment.LEFT)
assert aligned == text
+def test_align_text_has_unprintable():
+ text = 'foo\x02'
+ fill_char = '-'
+ width = 5
+ with pytest.raises(ValueError):
+ cu.align_text(text, fill_char=fill_char, width=width, alignment=cu.TextAlignment.LEFT)
+
def test_align_text_term_width():
import shutil
from cmd2 import ansi