def test_return_change(self): coins = give_change(.17) self.assertEqual(coins, [.10, .05, .02], 'wrong change given') self.assertEqual( give_change(.18), [.10, .05, .02, .01], )
def test_return_change(self): """ Method name has to start with test_ in order for it to run. The assertEqual method is inherited from unittest. """ coins = give_change(17) self.assertEqual(coins, [10, 5, 2], 'wrong change given') self.assertEqual(give_change(18), [10, 5, 2, 1], 'wrong change given')
def test_return_change(self): """ Method name has to start with test_ in order for it to run. The assertEqual method is inherited from unittest. """ self.assertEqual(give_change(.17), [.10, .05, .02]) self.assertEqual(give_change(.18), [.10, .05, .02, .01]) self.assertEqual(give_change(.04), [.02, .02])
def test_return_change(self): """ Method name has to start with test_ in order for it to run. Because we inherited from unittest.TestCase, we have some useful methods that we can use, such as assertEqual """ self.assertEqual(give_change(.17), [.10, .05, .02], 'wrong change given') self.assertEqual(give_change(.18), [.10, .05, .02, .01], 'wrong change given')
def test_return_change(self): # we're imaging there is a method called give_change which returns a list of coins # given in an amount in pence self.assertEqual(give_change(.17), [.10, .05, .02], 'wrong change given') self.assertEqual(give_change(18), [.10, .05, .02, .01], 'wrong change given') # decimal test self.assertEqual(give_change_decimal(.17), [.10, .05, .02], 'wrong change given') self.assertEqual(give_change_decimal(18), [.10, .05, .02, .01], 'wrong change given')
def test_give_USD_change(self): coins = vending_machine.give_change(USD_COINS, 82) self.assertEquals(coins, [50, 25, 5, 1, 1])
def test_multiple_same_coins(self): self.assertEqual(give_change(.04), [.02, .02])
def test_multiple_same_coins(self): self.assertEqual(give_change(4), [2, 2])
def test_return_change(self): self.assertEqual(give_change(17), [10, 5, 2], 'wrong change given') self.assertEqual(give_change(18), [10, 5, 2, 1], 'wrong change given') return
def test_return_one_cent(self): coins = vending_machine.give_change([1], 1) self.assertEquals(coins, [1])
def test_multiple_same_coins(self): """ test if change can be given in multiples of a coin """ self.assertEqual(give_change(.04), [.02, .02])
def test_multiple_same_coins(self): """test if change can be given in multiples of a coin """ self.assertEqual(give_change(.40), [.20, .20])
def test_return_change(self): self.assertEqual(give_change(0), [], 'wrong change given')
def test_return_no_change(self): coins = vending_machine.give_change([1], 0) self.assertEquals(coins, [])
def test_return_enough_ones(self): coins = vending_machine.give_change([1], 3) self.assertEquals(coins, [1, 1, 1])
def test_return_one_of_each_higher_denomination(self): coins = vending_machine.give_change([10, 5, 2, 1], 8) self.assertEquals(coins, [5, 2, 1])
def test_return_change(self): # we're imaging there is a method called give_change which returns a list of coins # given in an amount in pence self.assertEqual(give_change(17), [10, 5, 2], 'wrong change given') self.assertEqual(give_change(18), [10, 5, 2, 1], 'wrong change given')
def test_return_more_than_one_of_denomination(self): coins = vending_machine.give_change([10, 5, 2, 1], 29) self.assertEquals(coins, [10, 10, 5, 2, 2])
def test_denominations_dont_need_to_be_sorted(self): coins = vending_machine.give_change([1, 5, 10, 2], 57) self.assertEquals(coins, [10, 10, 10, 10, 10, 5, 2])
def test_return_change(self): coins = give_change(17) self.assertEqual(coins, [10, 5, 2], 'wrong change given') self.assertEqual(give_change(18), [10, 5, 2, 1], 'wrong change given')
def test_cant_give_exact_change(self): coins = vending_machine.give_change([2, 5, 10], 16) self.assertEquals(coins, [10, 5, 2])
def test_return_change(self): self.assertEqual(give_change(.17), [.10, .05, .02]) self.assertEqual(give_change(.18), [.10, .05, .02, .01]) self.assertEqual(give_change(.04), [.02, .02])
def test_give_EURO_change(self): coins = vending_machine.give_change(EURO_COINS, 82) self.assertEquals(coins, [50, 20, 10, 2])
def test_multiple_same_coins(self): """ machine accepts multiples of same coin""" self.assertEqual(give_change(.40), [.20, .20])