class YodleTest(unittest.TestCase): def setUp(self): self.change_machine = ChangeMachine([1,4,5,9]) def test_count_weights1(self): test_amount = 8 accepted_return = 2 coin_count = min_count_weights(test_amount, [1,4,5,9])[test_amount] self.assertEqual(coin_count,accepted_return) def test_count_weights2(self): test_amount = 10 accepted_return = 2 coin_count = min_count_weights(test_amount, [1,3,5,7])[test_amount] self.assertEqual(coin_count,accepted_return) def test_min_count_weights_rejects_float_target_value(self): self.assertRaises(TypeError, min_count_weights, 1.2, [1,2,3]) def test_min_count_weights_rejects_float_weights(self): self.assertRaises(TypeError, min_count_weights, 1, [1.,2,3]) def test_optimal_eight_cents_returned(self): test_amount = 8 accepted_return = [4,4] self.assertEqual(self.change_machine.make_optimal_change(test_amount), accepted_return) def test_Roman_seven_cents_returned(self): test_amount = 7 accepted_return = [5,1,1] self.assertEqual(self.change_machine.make_roman_change(test_amount), accepted_return) def test_Roman_twentyfour_cents_returned(self): test_amount = 24 accepted_return = [9,9,5,1] self.assertEqual(self.change_machine.make_roman_change(test_amount), accepted_return) def test_Roman_eight_cents_returned(self): test_amount = 8 accepted_return = [5,1,1,1] self.assertEqual(self.change_machine.make_roman_change(test_amount), accepted_return)
def setUp(self): self.change_machine = ChangeMachine([1,4,5,9])