def test_can_play_a_full_game(): app.consoleio = MockConsoleIO(['1', '1', '1', '', '', '1', '', '', '1', '1', '5', '2', '3', '7', '4', '6', '8', '9', 'n']) app.console = Console(app.consoleio) app.menu = Menu(app.console) app.main() assert app.consoleio.last_output == end_game_message()
def tic_tac_toe(): ''' This exercise is Part 4 of 4 of the Tic Tac Toe exercise series. The final step is to put all these three components together to make a two-player Tic Tac Toe game! Your challenge in this exercise is to use the functions from those previous exercises all together in the same program to make a two-player game that you can play with a friend. ''' import tic_tac_toe # Made a nicer version in a separate python file, so import from there tic_tac_toe.main()
def test_when_player_o_gets_tic_tac_toe_wins(caplog): input_values = [1, 4, 2, 5, 7, 6] def mock_input(s): return input_values.pop(0) tic_tac_toe.input = mock_input with pytest.raises(SystemExit): tic_tac_toe.main() assert 'Player O wins' in caplog.text
def test_when_all_nine_quarters_are_filled_the_game_is_a_draw(capsys): input_values = [1, 2, 5, 3, 6, 4, 7, 9, 8] def mock_input(s): return input_values.pop(0) tic_tac_toe.input = mock_input tic_tac_toe.main() out, err = capsys.readouterr() assert 'DRAW' in out
def test_when_player_selects_a_position_already_used_by_other_player_program_exits( ): input_values = [1, 1] def mock_input(s): return input_values.pop(0) tic_tac_toe.input = mock_input try: tic_tac_toe.main() except tic_tac_toe.PositionAlreadyPlayed: pass else: raise AssertionError("Expected a position not used")
def testMain(self): tic_tac_toe.main()
import tic_tac_toe import heart import soybean import landing_control import monks #List for names of datasets Datasets = [ "Tic-Tac-Toe Endgame Data Set", "SPECT Heart Data Set", "Soybean (Small) Data Set", "Shuttle Landing Control Data Set", "MONK's Problems Data Set 1", "MONK's Problems Data Set 2", "MONK's Problems Data Set 3" ] #List for accuracy calculated k = monks.main() Accuracy = [ tic_tac_toe.main(), heart.main(), soybean.main(), landing_control.main(), k[0], k[1], k[2] ] #Dictionary to be used as dataframe Results = {'Datasets': Datasets, 'Accuracy': Accuracy} #Write the results to an excel file df = pd.DataFrame(Results) writer = pd.ExcelWriter('Accuracy Table.xlsx') df.to_excel(writer, sheet_name='Sheet1', index=False) writer.save()