← run 2026-07-02T101616Z-9f192f9-minimal

bielik-11b-v3 — py-refactor

rep 1 PARTIAL 0/3

pi 54.3s · verify 0.6s · 4132 tok · responded: bielik-11b-v3 · transcript

verify output
.......                                                                  [100%]
7 passed in 0.01s
FFF                                                                      [100%]
=================================== FAILURES ===================================
________________ test_pricing_line_total_exists_and_is_correct _________________

    def test_pricing_line_total_exists_and_is_correct():
>       from shop.pricing import line_total
E       ImportError: cannot import name 'line_total' from 'shop.pricing' (/tmp/bench-ws-nw8wual0/shop/pricing.py)

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:23: ImportError
_______________________ test_orders_delegates_to_pricing _______________________

    def test_orders_delegates_to_pricing():
        src = _source("orders.py")
>       assert "line_total" in src, "orders.py should call pricing.line_total"
E       AssertionError: orders.py should call pricing.line_total
E       assert 'line_total' in '"""Order totals."""\n\n\ndef order_total(items):\n    """Total price for a list of order line items.\n\n    Each ``it...= 0.75\n        elif item["qty"] >= 10:\n            line *= 0.90\n        total += line\n    return round(total, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:31: AssertionError
________________________ test_cart_delegates_to_pricing ________________________

    def test_cart_delegates_to_pricing():
        src = _source("cart.py")
>       assert "line_total" in src, "cart.py should call pricing.line_total"
E       AssertionError: cart.py should call pricing.line_total
E       assert 'line_total' in '"""Shopping-cart totals."""\n\nFREE_SHIPPING_THRESHOLD = 50.0\nSHIPPING_FEE = 4.99\n\n\ndef cart_total(items):\n    "...\n    if subtotal >= FREE_SHIPPING_THRESHOLD:\n        return subtotal\n    return round(subtotal + SHIPPING_FEE, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:38: AssertionError
=========================== short test summary info ============================
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_pricing_line_total_exists_and_is_correct
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_orders_delegates_to_pricing
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_cart_delegates_to_pricing
3 failed in 0.01s
behaviour (gate): 7/7 preserved
structural (score): 0/3 refactor checks
score: 0%
produced code
.gitignore
__pycache__/
*.pyc
.pytest_cache/
shop/__init__.py

shop/cart.py
"""Shopping-cart totals."""

FREE_SHIPPING_THRESHOLD = 50.0
SHIPPING_FEE = 4.99


def cart_total(items):
    """Grand total for a cart: discounted line items plus shipping.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    The per-line discount rules are identical to ``order_total``:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    Shipping (``SHIPPING_FEE``) is added unless the discounted subtotal reaches
    ``FREE_SHIPPING_THRESHOLD``.
    """
    subtotal = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        subtotal += line
    subtotal = round(subtotal, 2)
    if subtotal >= FREE_SHIPPING_THRESHOLD:
        return subtotal
    return round(subtotal + SHIPPING_FEE, 2)
shop/orders.py
"""Order totals."""


def order_total(items):
    """Total price for a list of order line items.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    Per-line discount rules:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    The discounted line totals are summed and rounded to 2 decimals.
    """
    total = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        total += line
    return round(total, 2)
shop/pricing.py
"""Pricing helpers.

TODO: the per-line discount calculation currently lives (duplicated) in ``orders.py`` and
``cart.py``. It should be extracted here as ``line_total(price, qty, category)``.
"""
tests_visible/test_shop.py
import os
import sys

# Make the package importable no matter what directory pytest is invoked from.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from shop.orders import order_total
from shop.cart import cart_total


def test_order_no_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 20.0


def test_order_bulk_discount():
    assert order_total([{"price": 10.0, "qty": 10, "category": "std"}]) == 90.0


def test_order_clearance_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "clearance"}]) == 15.0


def test_cart_adds_shipping_below_threshold():
    assert cart_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 24.99


def test_cart_free_shipping_at_threshold():
    assert cart_total([{"price": 10.0, "qty": 5, "category": "std"}]) == 50.0

rep 2 PARTIAL 0/3

pi 44.7s · verify 0.6s · 3608 tok · responded: bielik-11b-v3 · transcript

verify output
.......                                                                  [100%]
7 passed in 0.01s
FFF                                                                      [100%]
=================================== FAILURES ===================================
________________ test_pricing_line_total_exists_and_is_correct _________________

    def test_pricing_line_total_exists_and_is_correct():
>       from shop.pricing import line_total
E       ImportError: cannot import name 'line_total' from 'shop.pricing' (/tmp/bench-ws-b_7qmbuk/shop/pricing.py)

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:23: ImportError
_______________________ test_orders_delegates_to_pricing _______________________

    def test_orders_delegates_to_pricing():
        src = _source("orders.py")
>       assert "line_total" in src, "orders.py should call pricing.line_total"
E       AssertionError: orders.py should call pricing.line_total
E       assert 'line_total' in '"""Order totals."""\n\n\ndef order_total(items):\n    """Total price for a list of order line items.\n\n    Each ``it...= 0.75\n        elif item["qty"] >= 10:\n            line *= 0.90\n        total += line\n    return round(total, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:31: AssertionError
________________________ test_cart_delegates_to_pricing ________________________

    def test_cart_delegates_to_pricing():
        src = _source("cart.py")
>       assert "line_total" in src, "cart.py should call pricing.line_total"
E       AssertionError: cart.py should call pricing.line_total
E       assert 'line_total' in '"""Shopping-cart totals."""\n\nFREE_SHIPPING_THRESHOLD = 50.0\nSHIPPING_FEE = 4.99\n\n\ndef cart_total(items):\n    "...\n    if subtotal >= FREE_SHIPPING_THRESHOLD:\n        return subtotal\n    return round(subtotal + SHIPPING_FEE, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:38: AssertionError
=========================== short test summary info ============================
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_pricing_line_total_exists_and_is_correct
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_orders_delegates_to_pricing
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_cart_delegates_to_pricing
3 failed in 0.01s
behaviour (gate): 7/7 preserved
structural (score): 0/3 refactor checks
score: 0%
produced code
.gitignore
__pycache__/
*.pyc
.pytest_cache/
shop/__init__.py

shop/cart.py
"""Shopping-cart totals."""

FREE_SHIPPING_THRESHOLD = 50.0
SHIPPING_FEE = 4.99


def cart_total(items):
    """Grand total for a cart: discounted line items plus shipping.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    The per-line discount rules are identical to ``order_total``:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    Shipping (``SHIPPING_FEE``) is added unless the discounted subtotal reaches
    ``FREE_SHIPPING_THRESHOLD``.
    """
    subtotal = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        subtotal += line
    subtotal = round(subtotal, 2)
    if subtotal >= FREE_SHIPPING_THRESHOLD:
        return subtotal
    return round(subtotal + SHIPPING_FEE, 2)
shop/orders.py
"""Order totals."""


def order_total(items):
    """Total price for a list of order line items.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    Per-line discount rules:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    The discounted line totals are summed and rounded to 2 decimals.
    """
    total = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        total += line
    return round(total, 2)
shop/pricing.py
"""Pricing helpers.

TODO: the per-line discount calculation currently lives (duplicated) in ``orders.py`` and
``cart.py``. It should be extracted here as ``line_total(price, qty, category)``.
"""
tests_visible/test_shop.py
import os
import sys

# Make the package importable no matter what directory pytest is invoked from.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from shop.orders import order_total
from shop.cart import cart_total


def test_order_no_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 20.0


def test_order_bulk_discount():
    assert order_total([{"price": 10.0, "qty": 10, "category": "std"}]) == 90.0


def test_order_clearance_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "clearance"}]) == 15.0


def test_cart_adds_shipping_below_threshold():
    assert cart_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 24.99


def test_cart_free_shipping_at_threshold():
    assert cart_total([{"price": 10.0, "qty": 5, "category": "std"}]) == 50.0

rep 3 PARTIAL 0/3

pi 25.4s · verify 0.6s · 2537 tok · responded: bielik-11b-v3 · transcript

verify output
.......                                                                  [100%]
7 passed in 0.01s
FFF                                                                      [100%]
=================================== FAILURES ===================================
________________ test_pricing_line_total_exists_and_is_correct _________________

    def test_pricing_line_total_exists_and_is_correct():
>       from shop.pricing import line_total
E       ImportError: cannot import name 'line_total' from 'shop.pricing' (/tmp/bench-ws-0crf1pox/shop/pricing.py)

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:23: ImportError
_______________________ test_orders_delegates_to_pricing _______________________

    def test_orders_delegates_to_pricing():
        src = _source("orders.py")
>       assert "line_total" in src, "orders.py should call pricing.line_total"
E       AssertionError: orders.py should call pricing.line_total
E       assert 'line_total' in '"""Order totals."""\n\n\ndef order_total(items):\n    """Total price for a list of order line items.\n\n    Each ``it...= 0.75\n        elif item["qty"] >= 10:\n            line *= 0.90\n        total += line\n    return round(total, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:31: AssertionError
________________________ test_cart_delegates_to_pricing ________________________

    def test_cart_delegates_to_pricing():
        src = _source("cart.py")
>       assert "line_total" in src, "cart.py should call pricing.line_total"
E       AssertionError: cart.py should call pricing.line_total
E       assert 'line_total' in '"""Shopping-cart totals."""\n\nFREE_SHIPPING_THRESHOLD = 50.0\nSHIPPING_FEE = 4.99\n\n\ndef cart_total(items):\n    "...\n    if subtotal >= FREE_SHIPPING_THRESHOLD:\n        return subtotal\n    return round(subtotal + SHIPPING_FEE, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:38: AssertionError
=========================== short test summary info ============================
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_pricing_line_total_exists_and_is_correct
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_orders_delegates_to_pricing
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_cart_delegates_to_pricing
3 failed in 0.01s
behaviour (gate): 7/7 preserved
structural (score): 0/3 refactor checks
score: 0%
produced code
.gitignore
__pycache__/
*.pyc
.pytest_cache/
shop/__init__.py

shop/cart.py
"""Shopping-cart totals."""

FREE_SHIPPING_THRESHOLD = 50.0
SHIPPING_FEE = 4.99


def cart_total(items):
    """Grand total for a cart: discounted line items plus shipping.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    The per-line discount rules are identical to ``order_total``:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    Shipping (``SHIPPING_FEE``) is added unless the discounted subtotal reaches
    ``FREE_SHIPPING_THRESHOLD``.
    """
    subtotal = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        subtotal += line
    subtotal = round(subtotal, 2)
    if subtotal >= FREE_SHIPPING_THRESHOLD:
        return subtotal
    return round(subtotal + SHIPPING_FEE, 2)
shop/orders.py
"""Order totals."""


def order_total(items):
    """Total price for a list of order line items.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    Per-line discount rules:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    The discounted line totals are summed and rounded to 2 decimals.
    """
    total = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        total += line
    return round(total, 2)
shop/pricing.py
"""Pricing helpers.

TODO: the per-line discount calculation currently lives (duplicated) in ``orders.py`` and
``cart.py``. It should be extracted here as ``line_total(price, qty, category)``.
"""
tests_visible/test_shop.py
import os
import sys

# Make the package importable no matter what directory pytest is invoked from.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from shop.orders import order_total
from shop.cart import cart_total


def test_order_no_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 20.0


def test_order_bulk_discount():
    assert order_total([{"price": 10.0, "qty": 10, "category": "std"}]) == 90.0


def test_order_clearance_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "clearance"}]) == 15.0


def test_cart_adds_shipping_below_threshold():
    assert cart_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 24.99


def test_cart_free_shipping_at_threshold():
    assert cart_total([{"price": 10.0, "qty": 5, "category": "std"}]) == 50.0

rep 4 PARTIAL 0/3

pi 24.8s · verify 0.6s · 2509 tok · responded: bielik-11b-v3 · transcript

verify output
.......                                                                  [100%]
7 passed in 0.01s
FFF                                                                      [100%]
=================================== FAILURES ===================================
________________ test_pricing_line_total_exists_and_is_correct _________________

    def test_pricing_line_total_exists_and_is_correct():
>       from shop.pricing import line_total
E       ImportError: cannot import name 'line_total' from 'shop.pricing' (/tmp/bench-ws-oot4h_pr/shop/pricing.py)

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:23: ImportError
_______________________ test_orders_delegates_to_pricing _______________________

    def test_orders_delegates_to_pricing():
        src = _source("orders.py")
>       assert "line_total" in src, "orders.py should call pricing.line_total"
E       AssertionError: orders.py should call pricing.line_total
E       assert 'line_total' in '"""Order totals."""\n\n\ndef order_total(items):\n    """Total price for a list of order line items.\n\n    Each ``it...= 0.75\n        elif item["qty"] >= 10:\n            line *= 0.90\n        total += line\n    return round(total, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:31: AssertionError
________________________ test_cart_delegates_to_pricing ________________________

    def test_cart_delegates_to_pricing():
        src = _source("cart.py")
>       assert "line_total" in src, "cart.py should call pricing.line_total"
E       AssertionError: cart.py should call pricing.line_total
E       assert 'line_total' in '"""Shopping-cart totals."""\n\nFREE_SHIPPING_THRESHOLD = 50.0\nSHIPPING_FEE = 4.99\n\n\ndef cart_total(items):\n    "...\n    if subtotal >= FREE_SHIPPING_THRESHOLD:\n        return subtotal\n    return round(subtotal + SHIPPING_FEE, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:38: AssertionError
=========================== short test summary info ============================
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_pricing_line_total_exists_and_is_correct
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_orders_delegates_to_pricing
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_cart_delegates_to_pricing
3 failed in 0.01s
behaviour (gate): 7/7 preserved
structural (score): 0/3 refactor checks
score: 0%
produced code
.gitignore
__pycache__/
*.pyc
.pytest_cache/
shop/__init__.py

shop/cart.py
"""Shopping-cart totals."""

FREE_SHIPPING_THRESHOLD = 50.0
SHIPPING_FEE = 4.99


def cart_total(items):
    """Grand total for a cart: discounted line items plus shipping.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    The per-line discount rules are identical to ``order_total``:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    Shipping (``SHIPPING_FEE``) is added unless the discounted subtotal reaches
    ``FREE_SHIPPING_THRESHOLD``.
    """
    subtotal = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        subtotal += line
    subtotal = round(subtotal, 2)
    if subtotal >= FREE_SHIPPING_THRESHOLD:
        return subtotal
    return round(subtotal + SHIPPING_FEE, 2)
shop/orders.py
"""Order totals."""


def order_total(items):
    """Total price for a list of order line items.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    Per-line discount rules:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    The discounted line totals are summed and rounded to 2 decimals.
    """
    total = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        total += line
    return round(total, 2)
shop/pricing.py
"""Pricing helpers.

TODO: the per-line discount calculation currently lives (duplicated) in ``orders.py`` and
``cart.py``. It should be extracted here as ``line_total(price, qty, category)``.
"""
tests_visible/test_shop.py
import os
import sys

# Make the package importable no matter what directory pytest is invoked from.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from shop.orders import order_total
from shop.cart import cart_total


def test_order_no_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 20.0


def test_order_bulk_discount():
    assert order_total([{"price": 10.0, "qty": 10, "category": "std"}]) == 90.0


def test_order_clearance_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "clearance"}]) == 15.0


def test_cart_adds_shipping_below_threshold():
    assert cart_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 24.99


def test_cart_free_shipping_at_threshold():
    assert cart_total([{"price": 10.0, "qty": 5, "category": "std"}]) == 50.0

rep 5 PARTIAL 0/3

pi 53.1s · verify 0.6s · 4073 tok · responded: bielik-11b-v3 · transcript

verify output
.......                                                                  [100%]
7 passed in 0.01s
FFF                                                                      [100%]
=================================== FAILURES ===================================
________________ test_pricing_line_total_exists_and_is_correct _________________

    def test_pricing_line_total_exists_and_is_correct():
>       from shop.pricing import line_total
E       ImportError: cannot import name 'line_total' from 'shop.pricing' (/tmp/bench-ws-ko7c_azd/shop/pricing.py)

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:23: ImportError
_______________________ test_orders_delegates_to_pricing _______________________

    def test_orders_delegates_to_pricing():
        src = _source("orders.py")
>       assert "line_total" in src, "orders.py should call pricing.line_total"
E       AssertionError: orders.py should call pricing.line_total
E       assert 'line_total' in '"""Order totals."""\n\n\ndef order_total(items):\n    """Total price for a list of order line items.\n\n    Each ``it...= 0.75\n        elif item["qty"] >= 10:\n            line *= 0.90\n        total += line\n    return round(total, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:31: AssertionError
________________________ test_cart_delegates_to_pricing ________________________

    def test_cart_delegates_to_pricing():
        src = _source("cart.py")
>       assert "line_total" in src, "cart.py should call pricing.line_total"
E       AssertionError: cart.py should call pricing.line_total
E       assert 'line_total' in '"""Shopping-cart totals."""\n\nFREE_SHIPPING_THRESHOLD = 50.0\nSHIPPING_FEE = 4.99\n\n\ndef cart_total(items):\n    "...\n    if subtotal >= FREE_SHIPPING_THRESHOLD:\n        return subtotal\n    return round(subtotal + SHIPPING_FEE, 2)\n'

/home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py:38: AssertionError
=========================== short test summary info ============================
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_pricing_line_total_exists_and_is_correct
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_orders_delegates_to_pricing
FAILED ../../home/lzieniew/Documents/my_local_llm_benchmarks/tasks/py-refactor/tests/test_structural.py::test_cart_delegates_to_pricing
3 failed in 0.02s
behaviour (gate): 7/7 preserved
structural (score): 0/3 refactor checks
score: 0%
produced code
.gitignore
__pycache__/
*.pyc
.pytest_cache/
shop/__init__.py

shop/cart.py
"""Shopping-cart totals."""

FREE_SHIPPING_THRESHOLD = 50.0
SHIPPING_FEE = 4.99


def cart_total(items):
    """Grand total for a cart: discounted line items plus shipping.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    The per-line discount rules are identical to ``order_total``:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    Shipping (``SHIPPING_FEE``) is added unless the discounted subtotal reaches
    ``FREE_SHIPPING_THRESHOLD``.
    """
    subtotal = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        subtotal += line
    subtotal = round(subtotal, 2)
    if subtotal >= FREE_SHIPPING_THRESHOLD:
        return subtotal
    return round(subtotal + SHIPPING_FEE, 2)
shop/orders.py
"""Order totals."""


def order_total(items):
    """Total price for a list of order line items.

    Each ``item`` is a dict with keys ``price`` (float), ``qty`` (int) and ``category`` (str).
    Per-line discount rules:
      * ``clearance`` category: 25% off
      * otherwise, quantity 10 or more: 10% off (bulk)
      * otherwise: no discount
    The discounted line totals are summed and rounded to 2 decimals.
    """
    total = 0.0
    for item in items:
        line = item["price"] * item["qty"]
        if item["category"] == "clearance":
            line *= 0.75
        elif item["qty"] >= 10:
            line *= 0.90
        total += line
    return round(total, 2)
shop/pricing.py
"""Pricing helpers.

TODO: the per-line discount calculation currently lives (duplicated) in ``orders.py`` and
``cart.py``. It should be extracted here as ``line_total(price, qty, category)``.
"""
tests_visible/test_shop.py
import os
import sys

# Make the package importable no matter what directory pytest is invoked from.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from shop.orders import order_total
from shop.cart import cart_total


def test_order_no_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 20.0


def test_order_bulk_discount():
    assert order_total([{"price": 10.0, "qty": 10, "category": "std"}]) == 90.0


def test_order_clearance_discount():
    assert order_total([{"price": 10.0, "qty": 2, "category": "clearance"}]) == 15.0


def test_cart_adds_shipping_below_threshold():
    assert cart_total([{"price": 10.0, "qty": 2, "category": "std"}]) == 24.99


def test_cart_free_shipping_at_threshold():
    assert cart_total([{"price": 10.0, "qty": 5, "category": "std"}]) == 50.0