summaryrefslogtreecommitdiffstats
path: root/contrib/python/wcwidth/py3/tests
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-02-09 14:18:13 +0300
committerrobot-piglet <[email protected]>2026-02-09 14:37:49 +0300
commitec4181e4ae8efc801e773ea358a493722d666231 (patch)
tree56620f4966dfdfcb74e750a6fd875180d325d4f8 /contrib/python/wcwidth/py3/tests
parent63535330a604fb3b8980f33ae6abbd046e4bce93 (diff)
Intermediate changes
commit_hash:0d521246940b8136d685e6a7302a677e00aea754
Diffstat (limited to 'contrib/python/wcwidth/py3/tests')
-rw-r--r--contrib/python/wcwidth/py3/tests/test_justify.py41
1 files changed, 24 insertions, 17 deletions
diff --git a/contrib/python/wcwidth/py3/tests/test_justify.py b/contrib/python/wcwidth/py3/tests/test_justify.py
index 55864bb23a5..71dec6199b6 100644
--- a/contrib/python/wcwidth/py3/tests/test_justify.py
+++ b/contrib/python/wcwidth/py3/tests/test_justify.py
@@ -10,13 +10,15 @@ EMOJI_FAMILY = '\U0001F468\u200D\U0001F469\u200D\U0001F467'
def test_ljust():
- assert ljust('hi', 5) == 'hi '
- assert ljust('', 5) == ' '
- assert ljust('hello', 3) == 'hello'
- assert ljust('hello', 5) == 'hello'
+ # our ljust() matches standard python ljust() for ascii
+ assert ljust('hi', 5) == 'hi ' == str.ljust('hi', 5)
+ assert ljust('', 5) == ' ' == str.ljust('', 5)
+ assert ljust('hello', 3) == 'hello' == str.ljust('hello', 3)
+ assert ljust('hello', 5) == 'hello' == str.ljust('hello', 5)
+ assert ljust('hi', 5, fillchar='-') == 'hi---' == str.ljust('hi', 5, '-')
+ # advanced capabilities
assert ljust('\x1b[31mhi\x1b[0m', 5) == '\x1b[31mhi\x1b[0m '
assert ljust('\u4e2d', 4) == '\u4e2d '
- assert ljust('hi', 5, fillchar='-') == 'hi---'
assert ljust('hi', 5, fillchar='\u00b7') == 'hi\u00b7\u00b7\u00b7'
assert ljust(CJK_WORD, 8) == CJK_WORD + ' '
assert width(ljust(CJK_WORD, 8)) == 8
@@ -27,13 +29,15 @@ def test_ljust():
def test_rjust():
- assert rjust('hi', 5) == ' hi'
- assert rjust('', 5) == ' '
- assert rjust('hello', 3) == 'hello'
- assert rjust('hello', 5) == 'hello'
+ # our rjust() matches standard python rjust() for ascii
+ assert rjust('hi', 5) == ' hi' == str.rjust('hi', 5)
+ assert rjust('', 5) == ' ' == str.rjust('', 5)
+ assert rjust('hello', 3) == 'hello' == str.rjust('hello', 3)
+ assert rjust('hello', 5) == 'hello' == str.rjust('hello', 5)
+ assert rjust('hi', 5, fillchar='-') == '---hi' == str.rjust('hi', 5, '-')
+ # advanced capabilities
assert rjust('\x1b[31mhi\x1b[0m', 5) == ' \x1b[31mhi\x1b[0m'
assert rjust('\u4e2d', 4) == ' \u4e2d'
- assert rjust('hi', 5, fillchar='-') == '---hi'
assert rjust('hi', 5, fillchar='\u00b7') == '\u00b7\u00b7\u00b7hi'
assert rjust(CJK_WORD, 8) == ' ' + CJK_WORD
assert width(rjust(CAFE_COMBINING, 8)) == 8
@@ -41,16 +45,19 @@ def test_rjust():
def test_center():
- assert center('hi', 6) == ' hi '
- assert center('hi', 5) == ' hi '
- assert center('', 4) == ' '
- assert center('hello', 3) == 'hello'
- assert center('hello', 5) == 'hello'
+ # our center() matches standard python center() for ascii
+ assert center('hi', 6) == ' hi ' == str.center('hi', 6)
+ assert center('hi', 5) == ' hi ' == str.center('hi', 5)
+ assert center('ab', 7) == ' ab ' == str.center('ab', 7)
+ assert center('', 4) == ' ' == str.center('', 4)
+ assert center('hello', 3) == 'hello' == str.center('hello', 3)
+ assert center('hello', 5) == 'hello' == str.center('hello', 5)
+ assert center('hi', 6, fillchar='-') == '--hi--' == str.center('hi', 6, '-')
+ assert center('x', 4) == ' x ' == str.center('x', 4)
+ # advanced capabilities
assert center('\x1b[31mhi\x1b[0m', 6) == ' \x1b[31mhi\x1b[0m '
assert center('\u4e2d', 6) == ' \u4e2d '
- assert center('hi', 6, fillchar='-') == '--hi--'
assert center('hi', 6, fillchar='\u00b7') == '\u00b7\u00b7hi\u00b7\u00b7'
- assert center('x', 4) == ' x '
assert width(center(CJK_WORD, 8)) == 8
assert width(center(CAFE_COMBINING, 8)) == 8
assert width(center(EMOJI_FAMILY, 6)) == 6