Items added to one cart show up in other carts
Done- Plan (done)
- Code (done)
- Test (done)
- Review (done)
- Finish (done)
Cost
$0.0028
Tests
Passed
Iterations
1
Re-plans
0
LLM calls
11
Prompt read from cache
80%
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 | 909 |
| coder | $0.0007 | 8,622 | 1,806 | 8 | 800 |
| tester | $0.0009 | 9,780 | 2,533 | 8 | 1,066 |
| reviewer | $0.0006 | 5,180 | 2,348 | 6 | 460 |
Timeline
-
planner iteration 1 Finished 3 calls · 7,244 tokens · $0.0006 · 7.8s
Loading…
-
coder iteration 1 Finished 3 calls · 11.2K tokens · $0.0007 · 6.7s
Loading…
-
tester iteration 1 Finished 3 calls · 13.4K tokens · $0.0009 · 9.6s
Loading…
-
verify iteration 1 Passed 0.5s
....... [100%] 7 passed in 0.02s
-
reviewer iteration 1 Finished 2 calls · 7,994 tokens · $0.0006 · 5.4s
Loading…
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..abffe54 100644 --- a/test_cart.py +++ b/test_cart.py @@ -5,3 +5,43 @@ def test_add_and_count(): cart = Cart(items=["a"]) cart.add("b") assert cart.count() == 2 + + +def test_carts_are_independent(): + cart1 = Cart() + cart2 = Cart() + cart1.add("a") + assert cart1.count() == 1 + assert cart2.count() == 0 + + +def test_input_list_not_mutated(): + lst = ["a"] + cart = Cart(items=lst) + cart.add("b") + assert lst == ["a"] + assert cart.count() == 2 + + +def test_empty_cart_count_is_zero(): + assert Cart().count() == 0 + + +def test_explicit_none_gives_empty_cart(): + cart = Cart(items=None) + assert cart.count() == 0 + cart.add("a") + assert cart.count() == 1 + + +def test_tuple_items_accepted(): + cart = Cart(items=("a",)) + cart.add("b") + assert cart.items == ["a", "b"] + + +def test_generator_items_consumed_into_cart(): + cart = Cart(items=(x for x in ["a", "b"])) + assert cart.count() == 2 + cart.add("c") + assert cart.count() == 3