From 9b6c976817819e7f01d4a5e42c4bf2db4ffefebf Mon Sep 17 00:00:00 2001 From: David Paul <dpaul4@une.edu.au> Date: Tue, 6 Dec 2016 11:02:31 +1100 Subject: [PATCH] Update exercises to use correct test --- exercises.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises.py b/exercises.py index c4ad8c8..eedcc0f 100644 --- a/exercises.py +++ b/exercises.py @@ -110,7 +110,7 @@ exercises.append(exercise) exercise = Exercise("Test-Driven Development") exercise.instructions = "An online store requires a Python function to calculate the price of orders. The function should be called <code>calculate_price</code> and take the following two arguments (in order):<ul><li><code>price</code>: A dictionary mapping the name of each item sold by the store to the price of the item (in dollars)</li><li><code>order</code>: A dictionary mapping the name of each item a customer wishes to buy to the quantity of that item they wish to purchase</li></ul>The function should iterate over each item in the order and add the price to buy the desired quantity of that item to the total cost of the order. If any item in the order does not have a corresponding price, your function should raise a <code>KeyError</code>.<p>Once the cost of each item in the order has been calculated, the function should test to see if the overall cost for all items is greater than $100. If it is, a 10% discount should be applied to the overall cost. Otherwise, if the order is greater than $50, a 5% discount should be applied.</p><p>The overall cost of the order (after any applicable discounts) should then be returned by the function.</p><p>Write a function to meet these requirements.</p>" exercise.code = "def calculate_price(price, order):\n\t# TODO: Implement this\n\tpass\n\nprice = {'book': 10.0, 'magazine': 5.5, 'newspaper': 2.0}\n\norder1 = {'book': 10}\norder2 = {'book': 1, 'magazine': 3}\norder3 = {'magazine': 5, 'book': 10}\n\nassert(95 == calculate_price(price, order1))\nassert(26.5 == calculate_price(price, order2))\nassert(114.75 == calculate_price(price, order3))\nprint(\"Done\")" -exercise.tests = [Test("Correct implementation", "Done")] +exercise.tests = [Test("Correct implementation", "Done\n")] exercise.checks = [Check("Please don't alter the assertions", "assert\\(95 == calculate_price\\(price, order1\\)\\)"), Check("Please don't alter the assertions", "assert\\(26.5 == calculate_price\\(price, order2\\)\\)"), Check("Please don't alter the assertions", "assert\\(114.75 == calculate_price\\(price, order3\\)\\)"), -- GitLab