import pytest from shipping import shipping_cost def test_small_domestic_order(): assert shipping_cost(20) == 5 @pytest.mark.parametrize( "subtotal, region, expected", [ (0, "domestic", 5), (49.99, "domestic", 5), (50, "domestic", 0), (50.01, "domestic", 0), (0, "international", 18), (20, "international", 18), (49.99, "international", 18), (50, "international", 12), (50.01, "international", 12), ], ) def test_shipping_rates(subtotal, region, expected): assert shipping_cost(subtotal, region) == expected @pytest.mark.parametrize("region", ["domestic", "international"]) def test_negative_subtotal(region): with pytest.raises(ValueError, match="^subtotal must be nonnegative$"): shipping_cost(-1, region) def test_unsupported_region(): with pytest.raises(ValueError, match="^unsupported region$"): shipping_cost(10, "unknown")