Skip to content

Instantly share code, notes, and snippets.

@klement97
Created January 4, 2021 21:14
Show Gist options
  • Save klement97/6162b28a8e5c149d2c9fc0b7ef8b8128 to your computer and use it in GitHub Desktop.
Save klement97/6162b28a8e5c149d2c9fc0b7ef8b8128 to your computer and use it in GitHub Desktop.
@pytest.mark.django_db
@pytest.mark.parametrize('number_of_toppings', list(range(0, 10)))
def test_pizza_price(number_of_toppings):
# Preparation phase
pizza = create_pizza(number_of_toppings=number_of_toppings)
# Calculating results
actual_price = pizza.total_price
expected_price = Decimal(sum([t.price for t in pizza.toppings.all()]))
# Assertion
assert actual_price == expected_price
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment