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

OpenCode 修复失败测试:Plan 分析、Build 修补与金额边界

修改前后 diff

--- a/app.py
+++ b/app.py
@@ -1,2 +1,4 @@
+from decimal import Decimal
+
 def subtotal(prices):
-    return round(sum(float(p) for p in prices), 2)
+    return sum((Decimal(p) for p in prices), Decimal('0')).quantize(Decimal('0.01'))

真实测试记录

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/opencode-failing-test-repair/before/test_app.py", line 7, in test_contract
    self.assertEqual(subtotal(['0.10', '0.20']), Decimal('0.30'))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 0.3 != Decimal('0.30')

----------------------------------------------------------------------
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

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