def test_get_player_symbol(self):
        input_mock = mock.Mock(side_effect=["banana", "x"])
        self.assertEqual(ioutil.get_player_symbol(input_mock, 1), "x")

        input_mock = mock.Mock(side_effect=["x"])
        self.assertEqual(ioutil.get_player_symbol(input_mock, 1), "x")

        input_mock = mock.Mock(side_effect=["garbage", "  ", "9 ", "\n\n", "え"])
        self.assertEqual(ioutil.get_player_symbol(input_mock, 1), "え")
    def test_get_player_symbol(self):
        input_mock = mock.Mock(side_effect=['banana', 'x'])
        self.assertEqual(ioutil.get_player_symbol(input_mock, 1), 'x')

        input_mock = mock.Mock(side_effect=['x'])
        self.assertEqual(ioutil.get_player_symbol(input_mock, 1), 'x')

        input_mock = mock.Mock(side_effect=['garbage', '  ', '9 ', '\n\n', 'え'])
        self.assertEqual(ioutil.get_player_symbol(input_mock, 1), 'え')
Пример #3
0
    def setup(self):
        """Performs game setup.

        This function repeatedly asks for ``num_of_players`` player names and
        their symbols. In further development, more setup tasks may be performed
        here.
        """
        for i in range(self.num_of_players):
            name = ioutil.get_player_name(i+1)
            symb = ioutil.get_player_symbol(input, i+1)
            self.players.append(player.Player(name, symb))