MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / TestPadToWidth

Class TestPadToWidth

tests/test_terminal_utils.py:114–172  ·  view source on GitHub ↗

Tests for pad_to_width function.

Source from the content-addressed store, hash-verified

112
113
114class TestPadToWidth:
115 """Tests for pad_to_width function."""
116
117 def test_left_align(self):
118 """Test left alignment (default)."""
119 result = pad_to_width("Hello", 10)
120 assert result == "Hello "
121 assert len(result) == 10
122
123 def test_right_align(self):
124 """Test right alignment."""
125 result = pad_to_width("Hello", 10, align="right")
126 assert result == " Hello"
127 assert len(result) == 10
128
129 def test_center_align(self):
130 """Test center alignment."""
131 result = pad_to_width("Test", 10, align="center")
132 assert result == " Test "
133 assert len(result) == 10
134
135 def test_center_align_odd(self):
136 """Test center alignment with odd padding."""
137 result = pad_to_width("Hi", 7, align="center")
138 # Should be: " Hi " or " Hi " (either is acceptable)
139 assert "Hi" in result
140 assert len(result) == 7
141
142 def test_chinese_padding(self):
143 """Test padding with Chinese characters."""
144 result = pad_to_width("你好", 10)
145 # "你好" is 4 display width, so needs 6 spaces
146 assert calculate_display_width(result) == 10
147
148 def test_emoji_padding(self):
149 """Test padding with emoji."""
150 result = pad_to_width("🤖", 10)
151 # "🤖" is 2 display width, so needs 8 spaces
152 assert calculate_display_width(result) == 10
153
154 def test_no_padding_needed(self):
155 """Test when text already reaches target width."""
156 result = pad_to_width("Hello", 5)
157 assert result == "Hello"
158
159 def test_text_exceeds_width(self):
160 """Test when text exceeds target width."""
161 result = pad_to_width("Hello World", 5)
162 assert result == "Hello World" # No truncation, just return as-is
163
164 def test_invalid_align(self):
165 """Test invalid alignment value."""
166 with pytest.raises(ValueError, match="Invalid align value"):
167 pad_to_width("Test", 10, align="invalid")
168
169 def test_custom_fill_char(self):
170 """Test custom fill character."""
171 result = pad_to_width("Test", 10, fill_char="-")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected