62
59
def test_split(self):
63
60
w = utextwrap.UTextWrapper()
64
self.assertEqual(w._split(_str_D), list(_str_D))
65
self.assertEqual(w._split(_str_SD), [_str_S]+list(_str_D))
66
self.assertEqual(w._split(_str_DS), list(_str_D)+[_str_S])
61
self.assertEqual(list(_str_D), w._split(_str_D))
62
self.assertEqual([_str_S]+list(_str_D), w._split(_str_SD))
63
self.assertEqual(list(_str_D)+[_str_S], w._split(_str_DS))
68
65
def test_wrap(self):
69
self.assertEqual(utextwrap.wrap(_str_D, 1), list(_str_D))
70
self.assertEqual(utextwrap.wrap(_str_D, 2), list(_str_D))
71
self.assertEqual(utextwrap.wrap(_str_D, 3), list(_str_D))
72
self.assertEqual(utextwrap.wrap(_str_D, 3, break_long_words=False),
66
self.assertEqual(list(_str_D), utextwrap.wrap(_str_D, 1))
67
self.assertEqual(list(_str_D), utextwrap.wrap(_str_D, 2))
68
self.assertEqual(list(_str_D), utextwrap.wrap(_str_D, 3))
69
self.assertEqual(list(_str_D),
70
utextwrap.wrap(_str_D, 3, break_long_words=False))
72
def test_fill_simple(self):
76
73
# Test only can call fill() because it's just '\n'.join(wrap(text)).
77
self.assertEqual(utextwrap.fill(_str_D, 4),
78
"%s\n%s" % (_str_D[:2], _str_D[2:]))
74
self.assertEqual("%s\n%s" % (_str_D[:2], _str_D[2:]),
75
utextwrap.fill(_str_D, 4))
77
def test_fill_with_breaks(self):
80
78
# Demonstrate complicated case.
81
79
text = u"spam ham egg spamhamegg" + _str_D + u" spam" + _str_D*2
83
utextwrap.fill(text, 8),
90
_str_D[2:]+_str_D[:2],
95
utextwrap.fill(text, 8, break_long_words=False),
100
# border between single width and double width.
103
_str_D[2:]+_str_D[:2],
107
def test_fill_indent(self):
108
w = utextwrap.UTextWrapper(8,
109
initial_indent=' '*4, subsequent_indent=' '*4)
111
self.assertEqual(w.fill(_str_SD),
119
w.break_long_words = False
121
self.assertEqual(w.fill(_str_SD),
80
self.assertEqual(u'\n'.join(["spam ham",
85
_str_D[2:]+_str_D[:2],
87
utextwrap.fill(text, 8))
89
def test_fill_without_breaks(self):
90
text = u"spam ham egg spamhamegg" + _str_D + u" spam" + _str_D*2
91
self.assertEqual(u'\n'.join(["spam ham",
94
# border between single width and double
98
_str_D[2:]+_str_D[:2],
100
utextwrap.fill(text, 8, break_long_words=False))
102
def test_fill_indent_with_breaks(self):
103
w = utextwrap.UTextWrapper(8, initial_indent=' '*4,
104
subsequent_indent=' '*4)
105
self.assertEqual(u'\n'.join([" hell",
112
def test_fill_indent_without_breaks(self):
113
w = utextwrap.UTextWrapper(8, initial_indent=' '*4,
114
subsequent_indent=' '*4)
115
w.break_long_words = False
116
self.assertEqual(u'\n'.join([" hello",
122
def test_fill_indent_without_breaks_with_fixed_width(self):
123
w = utextwrap.UTextWrapper(8, initial_indent=' '*4,
124
subsequent_indent=' '*4)
125
w.break_long_words = False
130
self.assertEqual(w.fill(_str_SD),
127
self.assertEqual(u'\n'.join([" hello",
140
136
# Regression test with Python's test_textwrap