refactor(cleanup): 移除剩余死代码模块
- 删除 douyin/utils/douyin_text_utils.py 及其测试 - 移除 performance_tracker.py 中未使用的 track_function 方法 - 移除 param_usage_tracer.py 中未使用的 stop_tracing / is_enabled - 清理 bin/run_cli.py 和 tests/test_imports.py 中的残留引用 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c4544489ac
commit
96fdc96f24
7 files changed
+3
-288
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"""douyin/logging/performance_tracker.PerformanceTracker 的 pytest 单元测试。
|
||||
|
||||
覆盖:start_timer / end_timer / get_elapsed / track_function / track_step /
|
||||
get_statistics 共 6 个方法。
|
||||
覆盖:start_timer / end_timer / get_elapsed / track_step /
|
||||
get_statistics 共 5 个方法。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -67,41 +67,6 @@ class TestGetElapsed:
|
||||
assert tracker.get_elapsed(t) == 0.0
|
||||
|
||||
|
||||
# ============================================================
|
||||
# track_function 装饰器
|
||||
# ============================================================
|
||||
|
||||
class TestTrackFunction:
|
||||
def test_wraps_and_returns_value(self, tracker):
|
||||
@tracker.track_function
|
||||
def add(a, b):
|
||||
return a + b
|
||||
|
||||
assert add(2, 3) == 5
|
||||
|
||||
def test_records_duration(self, tracker):
|
||||
@tracker.track_function
|
||||
def slow():
|
||||
time.sleep(0.01)
|
||||
|
||||
slow()
|
||||
stats = tracker.get_statistics()
|
||||
# 函数名 = "TestTrackFunction.test_records_duration.<locals>.slow"
|
||||
# 记录在以 qualname 为前缀的 key 上
|
||||
assert any("slow" in k for k in stats), f"未记录 slow 的统计:{stats}"
|
||||
|
||||
def test_exception_still_records(self, tracker):
|
||||
@tracker.track_function
|
||||
def raises():
|
||||
raise ValueError("boom")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
raises()
|
||||
stats = tracker.get_statistics()
|
||||
# 即使函数抛异常,时长也应被记录
|
||||
assert any("raises" in k for k in stats)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# track_step 装饰器
|
||||
# ============================================================
|
||||
|
||||
Reference in new issue
Block a user