Esempio n. 1
0
    def test_other_false(self):
        hand = [5, 6, 8]
        want = False
        got = average_even_is_average_odd(hand)

        self.assertEqual(
            want,
            got,
            msg=f'Expected {want} but got an incorrect result: {got!r}')
Esempio n. 2
0
    def test_instructions_example_2(self):
        hand = [1, 2, 3, 4]
        want = False
        got = average_even_is_average_odd(hand)

        self.assertEqual(
            want,
            got,
            msg=f'Expected {want} but got an incorrect result: {got!r}')
Esempio n. 3
0
    def test_average_even_is_average_odd(self):

        input_vars = [[5, 6, 8], [1, 2, 3, 4], [1, 2, 3], [5, 6, 7],
                      [1, 3, 5, 7, 9]]

        results = [False, False, True, True, True]

        for variant, (hand, same) in enumerate(zip(input_vars, results),
                                               start=1):
            error_message = f'Hand {hand} {"does" if same else "does not"} yield the same odd-even average.'
            with self.subTest(f'variation #{variant}', input=hand,
                              output=same):
                self.assertEqual(same,
                                 average_even_is_average_odd(hand),
                                 msg=error_message)