真实离线执行 · 人工参考修复

Continue 本地文档上下文:按 SLA 说明修复工作日计算

修改前后 diff

--- a/app.py
+++ b/app.py
@@ -1,4 +1,12 @@
 from datetime import timedelta
 
 def due_date(start, days):
-    return start + timedelta(days=days)
+    if days < 0:
+        raise ValueError('negative days')
+    cursor = start
+    remaining = days
+    while remaining:
+        cursor += timedelta(days=1)
+        if cursor.weekday() < 5:
+            remaining -= 1
+    return cursor

真实测试记录

before exit=1\ntest_contract (test_app.LessonTest.test_contract) ... FAIL

======================================================================
FAIL: test_contract (test_app.LessonTest.test_contract)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/lorin/my-clone/quickrout/public/downloads/tutorials-batch50b-20261014/practical/continue-local-doc-context/before/test_app.py", line 7, in test_contract
    self.assertEqual(due_date(date(2026,10,16), 1), date(2026,10,19))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: datetime.date(2026, 10, 17) != datetime.date(2026, 10, 19)

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)
\nfixed exit=0\ntest_contract (test_app.LessonTest.test_contract) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

标准库测试真实运行;参考代码人工编写,未执行 Continue 或付费模型。