11# coding=utf-8
22"""
3- Unit testing of tableformatter utility functtions .
3+ Unit testing of tableformatter utility functions .
44"""
55import pytest
66
1111def empty_text ():
1212 return ''
1313
14-
1514@pytest .fixture
1615def sample_text ():
1716 return 'FooBar'
1817
18+ @pytest .fixture
19+ def long_text ():
20+ return 'FooBarBaz'
21+
1922@pytest .fixture
2023def tabbed_text ():
2124 return 'Foo\t Bar'
2225
26+ @pytest .fixture
27+ def multiline_text ():
28+ return 'FooBar\n Baz'
29+
30+ @pytest .fixture
31+ def whitespace_text ():
32+ return 'FooBar \n '
33+
2334
2435# Test text wrapping
2536def test_empty_wrap (empty_text ):
@@ -37,6 +48,26 @@ def test_simple_wrap(sample_text):
3748 wrapped = tf ._text_wrap (sample_text , width = 3 )
3849 assert expected == wrapped
3950
51+ def test_double_wrap (long_text ):
52+ expected = ['Foo' , 'Bar' , 'Baz' ]
53+ wrapped = tf ._text_wrap (long_text , width = 3 )
54+ assert expected == wrapped
55+
56+ def test_multiline_no_wrap (multiline_text ):
57+ expected = ['FooBar Baz' ]
58+ wrapped = tf ._text_wrap (multiline_text )
59+ assert expected == wrapped
60+
61+ def test_multiline_with_wrap (multiline_text ):
62+ expected = ['Foo' , 'Bar' , 'Baz' ]
63+ wrapped = tf ._text_wrap (multiline_text , width = 3 )
64+ assert expected == wrapped
65+
66+ def test_trailing_whitespace_wrap (whitespace_text ):
67+ expected = ['FooBar' ]
68+ wrapped = tf ._text_wrap (whitespace_text )
69+ assert expected == wrapped
70+
4071
4172# Test tab translation and printable width calculation
4273def test_empty_translation (empty_text ):
0 commit comments