def test_getting_input(self): chosen_in = StringIO("hello\n") chosen_out = StringIO() io = InputOutput(chosen_in, chosen_out) given_input = io.get_input() self.assertEqual(given_input, "hello\n")
def test_printing(self): chosen_in = StringIO() chosen_out = StringIO() io = InputOutput(chosen_in, chosen_out) io.present("hello world") output = chosen_out.getvalue() self.assertEqual(output, "hello world\n")
def test_game_is_created_with_correct_players(self): io = InputOutput(StringIO(), StringIO()) game_loop = GameLoop(io) game_loop.create_game(self.player1, self.player2) self.assertEqual(self.player1, game_loop.game.player1) self.assertEqual(self.player2, game_loop.game.player2)
def setUp(self): self.chosen_out = StringIO() self.io = InputOutput(StringIO, self.chosen_out)
def setUp(self): self.chosen_output = StringIO() self.io = InputOutput(None, self.chosen_output) self.presenter = Presenter(self.io)
def test_evaluting_no_response_to_play_again_prompt(self): io = InputOutput(StringIO("c\nc\nno\n"), StringIO()) game_loop = GameLoop(io) game_loop.create_game(self.player1, self.player2) self.assertFalse(game_loop.play_again())
def test_game_is_created_with_proper_player_types(self): io = InputOutput(StringIO("human\ncomputer"), StringIO()) game_loop = GameLoop(io) self.assertTrue(isinstance(game_loop.game.player1, Human)) self.assertTrue(isinstance(game_loop.game.player2, Computer))