Move test runs into the test-run folder, add TimestampStrings, add basic tests via pytest

pytest added for dev.
Move all the test run python scripts into the "test-run" folder, so we can use the tests/ folder for just tests.

Setup one test for the TimestampStrings class with pytests in tests/unit/string_handling/test_timestamp_strings.py
This commit is contained in:
Clemens Schwaighofer
2025-07-08 14:54:26 +09:00
parent cd07267475
commit 060e3b4afe
12 changed files with 291 additions and 7 deletions

View File

@@ -0,0 +1,66 @@
#!/usr/bin/env -S uv run --script
"""
Test for double byte format
"""
from corelibs.string_handling.double_byte_string_format import DoubleByteFormatString
def main():
"""
Main call
"""
string = [
"Some string 123 other text",
"Some string 日本語 other text",
"日本語は string 123 other text",
"あいうえおかきくけこさしすせそなにぬねのまみむめも〜",
"あいうえおかきくけこさしす 1 other text",
"Some string すせそなにぬねのまみむめも〜",
"SOME OTHER STRING THAT IS LONGER THAN TWENTYSIX CHARACTERS",
"日本語は string 123 other text Some string 日本語 other text"
]
format_str = "{{:<{len}}}"
length_set = [
(26, 25),
(26, 26),
(26, 60),
(26, 20),
(26, -5),
(-6, -5),
]
for _length_set in length_set:
cut_length = _length_set[0]
format_length = _length_set[1]
print(f"========= Cut: {cut_length} | Format: {format_length} ==> ")
for _string in string:
string_test = DoubleByteFormatString(_string, cut_length, format_length)
formated = format_str.format(
len=string_test.get_format_length()
).format(
string_test.get_string_short()
)
print(
"* Shorten string: shorten length: "
f"Req: {string_test.get_requested_cut_length()} ({cut_length}) / "
f"Set: {string_test.get_cut_length()}, "
"format length: "
f"Req: {string_test.get_requested_format_length()} ({format_length}) / "
f"Set: {string_test.get_format_length()}"
f"\nOrig: |{_string}|"
f"\nGSS : |{string_test.get_string_short()}|"
f"\nF : |{formated}|"
f"\nGSSF: |{string_test.get_string_short_formated()}|"
)
print("-------")
if __name__ == "__main__":
main()
# __END__