Items added to one cart show up in other carts
Done- Plan (done)
- Code (done)
- Test (done)
- Review (done)
- Finish (done)
Cost
$0.0023
Tests
Passed
Iterations
1
Re-plans
0
LLM calls
9
Prompt read from cache
83%
Usage by agent
- Cache read
- Cache write
- Input
- Output
View as table
| Agent | Cost | Cache read | Cache write | Input | Output |
|---|---|---|---|---|---|
| planner | $0.0006 | 5,609 | 718 | 8 | 927 |
| coder | $0.0007 | 8,572 | 1,728 | 8 | 809 |
| tester | $0.0009 | 9,894 | 2,559 | 8 | 1,042 |
Timeline
-
planner iteration 1 Finished 3 calls · 7,262 tokens · $0.0006 · 6.8s
Loading…
-
coder iteration 1 Finished 3 calls · 11.1K tokens · $0.0007 · 5.8s
Loading…
-
tester iteration 1 Finished 3 calls · 13.5K tokens · $0.0009 · 9.8s
Loading…
-
verify iteration 1 Passed 0.5s
...... [100%] 6 passed in 0.01s
Final diff
diff --git a/cart.py b/cart.py index bff9b5d..9d4c165 100644 --- a/cart.py +++ b/cart.py @@ -1,6 +1,6 @@ class Cart: - def __init__(self, items=[]): - self.items = items + def __init__(self, items=None): + self.items = list(items) if items is not None else [] def add(self, item: str) -> None: self.items.append(item) diff --git a/test_cart.py b/test_cart.py index 2040527..e568f8b 100644 --- a/test_cart.py +++ b/test_cart.py @@ -5,3 +5,36 @@ def test_add_and_count(): cart = Cart(items=["a"]) cart.add("b") assert cart.count() == 2 + + +def test_carts_do_not_share_items(): + first = Cart() + first.add("x") + second = Cart() + assert second.count() == 0 + assert first.count() == 1 + + +def test_passed_list_is_not_mutated(): + original = ["a"] + cart = Cart(items=original) + cart.add("b") + assert original == ["a"] + assert cart.count() == 2 + + +def test_new_cart_is_empty(): + assert Cart().count() == 0 + + +def test_default_carts_have_distinct_item_lists(): + first = Cart() + second = Cart() + assert first.items is not second.items + + +def test_tuple_items_are_accepted(): + cart = Cart(items=("a",)) + cart.add("b") + assert cart.items == ["a", "b"] + assert cart.count() == 2