from unittest.mock import Mock import pytest from shop import checkout def test_checkout_charges_amount(): payment = Mock() assert checkout([10.0, 5.5], payment) == 15.5 payment.charge.assert_called_once_with(15.5) def test_checkout_empty(): payment = Mock() with pytest.raises(ValueError): checkout([], payment) payment.charge.assert_not_called()