@@ -374,41 +374,3 @@ class subbytearray(bytearray):
374374[file userdefinedbytes.py]
375375class bytes:
376376 pass
377-
378- [case testBytesRjustLjust]
379- def rjust_bytes(b: bytes, width: int, fill: bytes = b' ') -> bytes:
380- return b.rjust(width, fill)
381-
382- def ljust_bytes(b: bytes, width: int, fill: bytes = b' ') -> bytes:
383- return b.ljust(width, fill)
384-
385- def test_rjust_with_default_fill() -> None:
386- assert rjust_bytes(b'abc', 6) == b' abc'
387- assert rjust_bytes(b'abc', 3) == b'abc'
388- assert rjust_bytes(b'abc', 2) == b'abc'
389- assert rjust_bytes(b'', 4) == b' '
390-
391- def test_rjust_with_custom_fill() -> None:
392- assert rjust_bytes(b'abc', 6, b'0') == b'000abc'
393- assert rjust_bytes(b'abc', 5, b'_') == b'__abc'
394- assert rjust_bytes(b'abc', 3, b'X') == b'abc'
395-
396- def test_ljust_with_default_fill() -> None:
397- assert ljust_bytes(b'abc', 6) == b'abc '
398- assert ljust_bytes(b'abc', 3) == b'abc'
399- assert ljust_bytes(b'abc', 2) == b'abc'
400- assert ljust_bytes(b'', 4) == b' '
401-
402- def test_ljust_with_custom_fill() -> None:
403- assert ljust_bytes(b'abc', 6, b'0') == b'abc000'
404- assert ljust_bytes(b'abc', 5, b'_') == b'abc__'
405- assert ljust_bytes(b'abc', 3, b'X') == b'abc'
406-
407- def test_edge_cases() -> None:
408- assert rjust_bytes(b'abc', 0) == b'abc'
409- assert ljust_bytes(b'abc', 0) == b'abc'
410- # fillbyte must be length 1
411- with assertRaises(TypeError):
412- rjust_bytes(b'abc', 5, b'')
413- with assertRaises(TypeError):
414- ljust_bytes(b'abc', 5, b'12')
0 commit comments