P3: 删除 3 个永远 FAIL 的字符串匹配测试
这三个脚本都是 grep 源码字符串模式做"验证",匹配的代码模式在历次重构里 早已改名/拆分/删除,导致它们长期失败、永远不会再 PASS: - tests/test_delays.py 匹配的注释 "# 点击前延迟1秒" 已不存在于 douyin_yanghao.py - tests/validation/validate_fudai_mapping_recording.py 匹配的字符串如 "basic_join_decision:设置福袋信息并记录映射表"、 "_record_room_title_and_pos" 已不存在 - tests/validation/validate_reservation_lock_protection.py 匹配的 "参与成功,处理锁定期并移除预约"、"protection_seconds=10" 已不存在 继续保留只会误导新人;该补的是基于行为/接口的真单元测试(pytest 引入再说), 而不是字符串模式断言。tests/validation/ 目录因此变空,一并删除。 剩余 tests/test_filter_logging.py(业务函数测试)继续保留,仍 PASS。 回归:149 -> 146 .py,全量 compileall 通过;test_filter_logging / check_web_gui_config_sync 通过。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
5efa0ebc8b
commit
cc1d4f0897
3 files changed
-187
No files matched your search
@@ -1,61 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
测试养号延迟修改
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
|
||||
def test_delays():
|
||||
"""测试延迟设置是否正确"""
|
||||
print("=== 测试延迟设置 ===")
|
||||
|
||||
# 检查代码中是否包含正确的延迟调用
|
||||
with open(
|
||||
os.path.join(PROJECT_ROOT, "douyin", "other", "douyin_yanghao.py"),
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
) as f:
|
||||
content = f.read()
|
||||
|
||||
# 检查点击爱心前的延迟
|
||||
if "analyser.operation.delay(1.0) # 点击前延迟1秒" in content:
|
||||
print("✅ 爱心点击前延迟1秒 - 正确")
|
||||
else:
|
||||
print("❌ 爱心点击前延迟未找到")
|
||||
|
||||
# 检查点击爱心后的延迟
|
||||
if "analyser.operation.delay(1.0) # 点击后延迟1秒" in content:
|
||||
print("✅ 爱心点击后延迟1秒 - 正确")
|
||||
else:
|
||||
print("❌ 爱心点击后延迟未找到")
|
||||
|
||||
# 检查点击收藏前的延迟
|
||||
if content.count("analyser.operation.delay(1.0) # 点击前延迟1秒") >= 2:
|
||||
print("✅ 收藏点击前延迟1秒 - 正确")
|
||||
else:
|
||||
print("❌ 收藏点击前延迟未找到")
|
||||
|
||||
# 检查点击收藏后的延迟
|
||||
if content.count("analyser.operation.delay(1.0) # 点击后延迟1秒") >= 2:
|
||||
print("✅ 收藏点击后延迟1秒 - 正确")
|
||||
else:
|
||||
print("❌ 收藏点击后延迟未找到")
|
||||
|
||||
# 检查推荐页流程的延迟
|
||||
if (
|
||||
content.count("analyser.operation.delay(1.0)") >= 4
|
||||
): # 2个点击延迟 + 2个推荐页延迟
|
||||
print("✅ 推荐页流程延迟1秒 - 正确")
|
||||
else:
|
||||
print("❌ 推荐页流程延迟不完整")
|
||||
|
||||
print("\n=== 延迟设置验证完成 ===")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_delays()
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
验证福袋详情识别完成后映射表记录功能的脚本
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
|
||||
def validate_fudai_mapping_recording():
|
||||
"""验证福袋详情识别完成后映射表记录功能"""
|
||||
print("开始验证福袋详情识别完成后映射表记录功能...")
|
||||
|
||||
# 检查代码模式
|
||||
patterns_to_check = [
|
||||
"analyser._current_fudai_content = content",
|
||||
"analyser._last_fudai_detail_tuple = detail",
|
||||
"basic_join_decision:设置福袋信息并记录映射表",
|
||||
"_record_room_title_and_pos",
|
||||
]
|
||||
|
||||
# 读取文件内容
|
||||
file_path = os.path.join(PROJECT_ROOT, "douyin", "fudai", "douyin_fudai_core.py")
|
||||
try:
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
except Exception as e:
|
||||
print(f"❌ 无法读取文件 {file_path}: {e}")
|
||||
return False
|
||||
|
||||
# 检查每个模式
|
||||
missing_patterns = []
|
||||
for pattern in patterns_to_check:
|
||||
if pattern not in content:
|
||||
missing_patterns.append(pattern)
|
||||
|
||||
if missing_patterns:
|
||||
print("❌ 缺少以下代码模式:")
|
||||
for pattern in missing_patterns:
|
||||
print(f" - {pattern}")
|
||||
return False
|
||||
|
||||
print("✅ 福袋详情识别完成后映射表记录功能验证通过")
|
||||
print(" - 福袋属性设置代码存在")
|
||||
print(" - 映射表记录调用存在")
|
||||
print(" - 记录时机正确(在basic_join_decision开始时)")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = validate_fudai_mapping_recording()
|
||||
sys.exit(0 if success else 1)
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
验证预约福袋参与成功后锁定期保护逻辑
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.insert(0, PROJECT_ROOT)
|
||||
|
||||
|
||||
def validate_reservation_lock_protection():
|
||||
"""验证预约福袋参与成功后锁定期保护逻辑"""
|
||||
print("开始验证预约福袋参与成功后锁定期保护逻辑...")
|
||||
|
||||
# 检查代码模式
|
||||
patterns_to_check = [
|
||||
"参与成功,处理锁定期并移除预约",
|
||||
"has_other_reservations",
|
||||
"设置保护期确保依次参与",
|
||||
"protection_seconds=10",
|
||||
"参与成功,清除锁定期(无其他预约)",
|
||||
]
|
||||
|
||||
# 读取文件内容
|
||||
file_path = os.path.join(PROJECT_ROOT, "douyin", "core", "douyin_fudai.py")
|
||||
try:
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
except Exception as e:
|
||||
print(f"❌ 无法读取文件 {file_path}: {e}")
|
||||
return False
|
||||
|
||||
# 检查每个模式
|
||||
missing_patterns = []
|
||||
for pattern in patterns_to_check:
|
||||
if pattern not in content:
|
||||
missing_patterns.append(pattern)
|
||||
|
||||
if missing_patterns:
|
||||
print("❌ 缺少以下代码模式:")
|
||||
for pattern in missing_patterns:
|
||||
print(f" - {pattern}")
|
||||
return False
|
||||
|
||||
# 检查保护期逻辑是否存在
|
||||
protection_logic_found = (
|
||||
"has_other_reservations = False" in content
|
||||
and "if has_other_reservations:" in content
|
||||
and "protection_until = time.time() + 10.0" in content
|
||||
and "max(self.reservation_focus_until_ts, protection_until)" in content
|
||||
)
|
||||
|
||||
if not protection_logic_found:
|
||||
print("❌ 保护期设置逻辑不完整")
|
||||
return False
|
||||
|
||||
print("✅ 预约福袋参与成功后锁定期保护逻辑验证通过")
|
||||
print(" - 参与成功后检查是否有其他预约")
|
||||
print(" - 有其他预约时设置10秒保护期")
|
||||
print(" - 无其他预约时清除锁定期")
|
||||
print(" - 确保预约福袋依次参与,不被其他预约打断")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = validate_reservation_lock_protection()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in new issue
Block a user