Ejemplo n.º 1
0
    def test_list_contains_round(self):

        input_vars = [
            ([], 1),
            ([1, 2, 3], 0),
            ([27, 28, 29, 35, 36], 30),
            ([1], 1),
            ([1, 2, 3], 1),
            ([27, 28, 29, 35, 36], 29),
        ]

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

        for variant, ((rounds, round_number),
                      contains) in enumerate(zip(input_vars, results),
                                             start=1):
            error_message = (
                f'Round {round_number} {"is" if contains else "is not"} in {rounds}.'
            )
            with self.subTest(f"variation #{variant}",
                              input=(rounds, round_number),
                              output=contains):
                self.assertEqual(
                    contains,
                    list_contains_round(rounds, round_number),
                    msg=error_message,
                )
Ejemplo n.º 2
0
    def test_empty(self):
        rounds = []
        round_number = 1
        want = False
        got = list_contains_round(rounds, round_number)

        self.assertEqual(
            want,
            got,
            msg=f'Expected {want} but got an incorrect result: {got!r}')
Ejemplo n.º 3
0
    def test_instructions_example_2(self):
        rounds = [27, 28, 29, 35, 36]
        round_number = 30
        want = False
        got = list_contains_round(rounds, round_number)

        self.assertEqual(
            want,
            got,
            msg=f'Expected {want} but got an incorrect result: {got!r}')
Ejemplo n.º 4
0
    def test_other_false(self):
        rounds = [1, 2, 3]
        round_number = 0
        want = False
        got = list_contains_round(rounds, round_number)

        self.assertEqual(
            want,
            got,
            msg=f'Expected {want} but got an incorrect result: {got!r}')