mirror of
https://github.com/Nanaloveyuki/py-logiliteal.git
synced 2025-09-03 18:16:22 +00:00
✅ message
富文本功能基本测试完成
This commit is contained in:
53
tests/t-color-priority.py
Normal file
53
tests/t-color-priority.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
测试颜色优先级处理功能
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
project_root = Path(__file__).parent.parent
|
||||||
|
sys.path.append(str(project_root))
|
||||||
|
|
||||||
|
# 添加项目根目录到Python路径
|
||||||
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
|
||||||
|
from src.logiliteal.utils.fmt import fmt_message
|
||||||
|
|
||||||
|
def test_color_priority():
|
||||||
|
"""测试颜色优先级"""
|
||||||
|
print("=== 颜色优先级测试 ===")
|
||||||
|
|
||||||
|
# 测试1: 基本颜色标签
|
||||||
|
test1 = "<#ff0000>红色文本</>"
|
||||||
|
print(f"基本颜色: {test1}")
|
||||||
|
print(f"结果: {fmt_message(test1)}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
# 测试2: 嵌套颜色(内层优先级高)
|
||||||
|
test2 = "<#ff0000>外层<#00ff00>内层</>外层</>"
|
||||||
|
print(f"嵌套颜色: {test2}")
|
||||||
|
print(f"结果: {fmt_message(test2)}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
# 测试3: 颜色重叠测试(最后边颜色为主)
|
||||||
|
test3 = "<#ff0000>颜色重叠<#0000ff>测<#ff00c2>试</></></>"
|
||||||
|
print(f"颜色重叠: {test3}")
|
||||||
|
print(f"结果: {fmt_message(test3)}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
# 测试4: 多层嵌套
|
||||||
|
test4 = "<#ff0000>1<#00ff00>2<#0000ff>3<#ffff00>4</>3</>2</>1</>"
|
||||||
|
print(f"多层嵌套: {test4}")
|
||||||
|
print(f"结果: {fmt_message(test4)}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
# 测试5: 未闭合标签(忽略)
|
||||||
|
test5 = "<#ff0000>未闭合标签"
|
||||||
|
print(f"未闭合标签: {test5}")
|
||||||
|
print(f"结果: {fmt_message(test5)}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_color_priority()
|
34
tests/t-fmt-text.py
Normal file
34
tests/t-fmt-text.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
project_root = Path(__file__).parent.parent
|
||||||
|
sys.path.append(str(project_root))
|
||||||
|
|
||||||
|
from src.logiliteal.levels import Logger
|
||||||
|
|
||||||
|
log = Logger()
|
||||||
|
|
||||||
|
log.info("<i>html斜体</i>")
|
||||||
|
log.info("<b>html加粗</b>")
|
||||||
|
log.info("<u>html下划线</u>")
|
||||||
|
log.info("<s>html删除线</s>")
|
||||||
|
log.info("<p>html段落</p>")
|
||||||
|
log.info("<a href=\"https://www.baidu.com\">html超链接</a>")
|
||||||
|
log.info("**Markdown加粗**")
|
||||||
|
log.info("*Markdown斜体*")
|
||||||
|
log.info("`Markdown代码块`")
|
||||||
|
log.info("~~Markdown删除线~~\n")
|
||||||
|
log.info("[md超链接](https://www.baidu.com)")
|
||||||
|
log.info("--测试<i>重复--")
|
||||||
|
log.info("<#ff0000>颜色重叠<#0000ff>测<#ff00c2>试</></></>")
|
||||||
|
log.info("<a href=\"https://www.baidu.com\">超<link href=\"https://www.bing.cn\">链接[重叠](https://www.360.com)</link></a>")
|
||||||
|
|
||||||
|
"""
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
log.info(get_asctime())
|
||||||
|
time.sleep(1)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
log.info("测试结束")
|
||||||
|
break
|
||||||
|
"""
|
@ -1,25 +0,0 @@
|
|||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
import time
|
|
||||||
|
|
||||||
project_root = Path(__file__).parent.parent
|
|
||||||
sys.path.append(str(project_root))
|
|
||||||
|
|
||||||
from src.logiliteal.utils.time import get_asctime, get_time, get_date, get_weekday
|
|
||||||
from src.logiliteal.levels import Logger
|
|
||||||
|
|
||||||
log = Logger()
|
|
||||||
|
|
||||||
log.info(get_asctime())
|
|
||||||
log.info(get_time())
|
|
||||||
log.info(get_date())
|
|
||||||
log.info(get_weekday())
|
|
||||||
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
log.info(get_asctime())
|
|
||||||
time.sleep(1)
|
|
||||||
log.info("时间分割线")
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
log.info("测试结束")
|
|
||||||
break
|
|
Reference in New Issue
Block a user