这pytest也太奇怪了吧

This commit is contained in:
2025-08-20 19:30:37 +08:00
parent f50e27d03b
commit 8065ffc06a
5 changed files with 25 additions and 25 deletions

31
main.py
View File

@@ -42,12 +42,11 @@
通知将在合适时间发送可使用时间轮算法完成周、日的课程安排但需要先对reader返回的课程时间进行解析。该脚本将持续运行并检测安排在合适的时间发送通知
"""
import time
import datetime
from typing import List
import reader
import informer
import time
import informer
import reader
# 课程时间安排
CLASS_SCHEDULE = {
@@ -102,7 +101,7 @@ def _get_current_week(start_date: datetime.date = datetime.date(2025, 8, 25)) ->
today = datetime.date.today()
delta = today - start_date
week = delta.days // 7 + 1
return max(week, 1) # 确保至少为第1周
return week # 确保至少为第1周
def _get_notification_time(period: str, timeslot_from: int) -> str:
@@ -290,37 +289,37 @@ def _test_day_notifications(courses, current_week: int, current_day: str, day_na
# _send_course_notification(course, course.period)
def test_notification_logic():
def _test_notification_logic():
"""测试方法:模拟第一周第一天、第二天、第三天的课程安排通知逻辑"""
print("开始测试通知逻辑...")
try:
# 读取课程信息
student_info, courses = reader.read_course_schedule()
print(f"已读取 {len(courses)} 门课程信息")
# 模拟第一周
current_week = 1
print(f"模拟第 {current_week}")
# 测试第一天(星期一)
_test_day_notifications(courses, current_week, "星期一", "第一天(星期一)")
# 测试第二天(星期二)
_test_day_notifications(courses, current_week, "星期二", "第二天(星期二)")
# 测试第三天(星期三)
_test_day_notifications(courses, current_week, "星期三", "第三天(星期三)")
print("\n测试完成")
except Exception as e:
print(f"测试过程中出错: {e}")
if __name__ == "__main__":
# 运行测试方法
test_notification_logic()
# _test_notification_logic()
# 如果要运行主方法,取消下面的注释
# main()
main()