@@ -248,37 +248,50 @@ def test_multiline_cells():
248
248
assert text == expected
249
249
250
250
251
- def test_east_asian_wide_characters_and_zero_width ():
252
- # using len () to count the number of characters
251
+ def test_east_asian_wide_characters_and_zero_width_wcwidth ():
252
+ # using wcwidth.wcswidth () to count the number of characters
253
253
text = t2a (
254
- header = ["日期" , "test" ],
255
- body = [["2022/12/11" , "test" ], ["2022/1/1" , "測試" ]],
256
- cell_padding = 5 ,
257
- use_wcwidth = False ,
254
+ header = ["#\u200b " , "🦁" , "🦡" , "🦅" , "🐍" ],
255
+ body = [["💻" , "✅" , "✅" , "❌" , "❌" ]],
256
+ footer = ["🥞" , "日" , "月" , "火" , "水" ],
257
+ first_col_heading = True ,
258
+ )
259
+ text2 = t2a (
260
+ header = ["#\u200b " , "🦁" , "🦡" , "🦅" , "🐍" ],
261
+ body = [["💻" , "✅" , "✅" , "❌" , "❌" ]],
262
+ footer = ["🥞" , "日" , "月" , "火" , "水" ],
263
+ first_col_heading = True ,
264
+ use_wcwidth = True ,
258
265
)
259
266
expected = (
260
- "╔═══════════════════════════════════╗\n "
261
- "║ 日期 test ║\n "
262
- "╟───────────────────────────────────╢\n "
263
- "║ 2022/12/11 test ║\n "
264
- "║ 2022/1/1 測試 ║\n "
265
- "╚═══════════════════════════════════╝"
267
+ "╔════╦═══════════════════╗\n "
268
+ "║ # ║ 🦁 🦡 🦅 🐍 ║\n "
269
+ "╟────╫───────────────────╢\n "
270
+ "║ 💻 ║ ✅ ✅ ❌ ❌ ║\n "
271
+ "╟────╫───────────────────╢\n "
272
+ "║ 🥞 ║ 日 月 火 水 ║\n "
273
+ "╚════╩═══════════════════╝"
266
274
)
267
275
assert text == expected
276
+ assert text2 == expected
268
277
269
- # using wcwidth.wcswidth() to count the number of characters
278
+
279
+ def test_east_asian_wide_characters_and_zero_width_no_wcwidth ():
280
+ # using len() to count the number of characters
270
281
text = t2a (
271
- header = ["日期" , "test" ],
272
- body = [["2022/12/11" , "test" ], ["2022/1/1" , "測試" ]],
273
- cell_padding = 5 ,
274
- use_wcwidth = True ,
282
+ header = ["#\u200b " , "🦁" , "🦡" , "🦅" , "🐍" ],
283
+ body = [["💻" , "✅" , "✅" , "❌" , "❌" ]],
284
+ footer = ["🥞" , "日" , "月" , "火" , "水" ],
285
+ first_col_heading = True ,
286
+ use_wcwidth = False ,
275
287
)
276
288
expected = (
277
- "╔═══════════════════════════════════╗\n "
278
- "║ 日期 test ║\n "
279
- "╟───────────────────────────────────╢\n "
280
- "║ 2022/12/11 test ║\n "
281
- "║ 2022/1/1 測試 ║\n "
282
- "╚═══════════════════════════════════╝"
289
+ "╔════╦═══════════════╗\n "
290
+ "║ # ║ 🦁 🦡 🦅 🐍 ║\n "
291
+ "╟────╫───────────────╢\n "
292
+ "║ 💻 ║ ✅ ✅ ❌ ❌ ║\n "
293
+ "╟────╫───────────────╢\n "
294
+ "║ 🥞 ║ 日 月 火 水 ║\n "
295
+ "╚════╩═══════════════╝"
283
296
)
284
297
assert text == expected
0 commit comments