refactor(cleanup): 移除 logging 模块死代码
- unified_logger.py: 删除 5 个从未使用的装饰器/函数 - internal_loggers.py: 删除 3 个未使用方法和工厂函数 - action_logger.py: 删除 3 个未使用方法 - log_formatter.py: 删除 6 个未使用格式化函数(保留 GUI 依赖的 4 个) - 同步更新 __init__.py 和测试文件 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
703da834fb
commit
d19d5bfc56
8 files changed
+12
-482
No files matched your search
@@ -1,9 +1,8 @@
|
||||
"""douyin/logging/log_formatter 的 pytest 单元测试。
|
||||
|
||||
覆盖 9 个格式化纯函数:
|
||||
覆盖格式化纯函数:
|
||||
- format_action_log / format_debug_log / format_error_log
|
||||
- format_parameters / format_variables / format_call_stack
|
||||
- format_exception / add_colors / add_separators
|
||||
- add_colors
|
||||
- beautify_log_output / colorize_log_line(一致性 + 不抛断言)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
@@ -67,64 +66,7 @@ class TestFormatErrorLog:
|
||||
|
||||
|
||||
# ============================================================
|
||||
# format_parameters / format_variables
|
||||
# ============================================================
|
||||
|
||||
class TestFormatParametersVariables:
|
||||
def test_format_parameters_with_data(self):
|
||||
result = f.format_parameters({"a": 1, "b": "x"})
|
||||
assert "a=1" in result
|
||||
assert "b=x" in result
|
||||
|
||||
def test_format_parameters_empty(self):
|
||||
assert f.format_parameters({}) == ""
|
||||
|
||||
def test_format_variables_with_data(self):
|
||||
result = f.format_variables({"k": "v"})
|
||||
assert "k=v" in result
|
||||
|
||||
def test_format_variables_empty(self):
|
||||
assert f.format_variables({}) == ""
|
||||
|
||||
|
||||
# ============================================================
|
||||
# format_call_stack
|
||||
# ============================================================
|
||||
|
||||
class TestFormatCallStack:
|
||||
def test_empty(self):
|
||||
assert f.format_call_stack() == ""
|
||||
|
||||
def test_with_frames(self):
|
||||
result = f.format_call_stack(["frame1", "frame2"])
|
||||
assert "frame1" in result
|
||||
assert "frame2" in result
|
||||
|
||||
|
||||
# ============================================================
|
||||
# format_exception
|
||||
# ============================================================
|
||||
|
||||
class TestFormatException:
|
||||
def test_includes_traceback(self):
|
||||
try:
|
||||
raise RuntimeError("boom")
|
||||
except RuntimeError as e:
|
||||
result = f.format_exception(e)
|
||||
assert "RuntimeError" in result
|
||||
assert "boom" in result
|
||||
|
||||
def test_returns_string(self):
|
||||
try:
|
||||
raise ValueError("bad")
|
||||
except ValueError as e:
|
||||
result = f.format_exception(e)
|
||||
assert isinstance(result, str)
|
||||
assert len(result) > 0
|
||||
|
||||
|
||||
# ============================================================
|
||||
# add_colors / add_separators
|
||||
# add_colors
|
||||
# ============================================================
|
||||
|
||||
class TestAddColors:
|
||||
@@ -146,20 +88,6 @@ class TestAddColors:
|
||||
assert "hi" in result
|
||||
|
||||
|
||||
class TestAddSeparators:
|
||||
def test_with_label(self):
|
||||
result = f.add_separators("content", label="SECTION")
|
||||
assert "content" in result
|
||||
assert "SECTION" in result
|
||||
# 包含分隔线
|
||||
assert "=" * 80 in result
|
||||
|
||||
def test_without_label(self):
|
||||
result = f.add_separators("content")
|
||||
assert "content" in result
|
||||
assert "=" * 80 in result
|
||||
|
||||
|
||||
# ============================================================
|
||||
# beautify_log_output / colorize_log_line(一致性 / 不抛)
|
||||
# ============================================================
|
||||
|
||||
Reference in new issue
Block a user