()
| 70 | |
| 71 | |
| 72 | def test_getPlayerMove(): |
| 73 | blankBoard = fourinarow.getNewBoard() |
| 74 | |
| 75 | # Test valid moves: |
| 76 | for i in range(1, 8): |
| 77 | sys.stdin = io.StringIO(str(i) + '\n') |
| 78 | assert fourinarow.getPlayerMove('X', blankBoard) == (i - 1, 5) |
| 79 | |
| 80 | # Test quitting: |
| 81 | with pytest.raises(SystemExit): |
| 82 | sys.stdin = io.StringIO('QUIT\n') |
| 83 | fourinarow.getPlayerMove('X', blankBoard) |
| 84 | |
| 85 | with pytest.raises(SystemExit): |
| 86 | sys.stdin = io.StringIO('quit\n') |
| 87 | fourinarow.getPlayerMove('X', blankBoard) |
| 88 | |
| 89 | with pytest.raises(SystemExit): |
| 90 | sys.stdin = io.StringIO('qUiT\n') |
| 91 | fourinarow.getPlayerMove('X', blankBoard) |
| 92 | |
| 93 | with pytest.raises(SystemExit): |
| 94 | sys.stdin = io.StringIO(' quit \n') |
| 95 | fourinarow.getPlayerMove('X', blankBoard) |
| 96 | |
| 97 | # Test invalid move: |
| 98 | sys.stdin = io.StringIO('invalid\n1\n') |
| 99 | assert fourinarow.getPlayerMove('X', blankBoard) == (0, 5) |
| 100 | |
| 101 | # Test stacking move: |
| 102 | board = fourinarow.getNewBoard() |
| 103 | board[(0, 5)] = 'X' |
| 104 | board[(0, 4)] = 'X' |
| 105 | board[(0, 3)] = 'X' |
| 106 | sys.stdin = io.StringIO('1\n') |
| 107 | assert fourinarow.getPlayerMove('X', board) == (0, 2) |
| 108 | |
| 109 | # Test when the column is full: |
| 110 | board = fourinarow.getNewBoard() |
| 111 | for i in range(6): |
| 112 | board[(0, i)] = 'X' |
| 113 | sys.stdin = io.StringIO('1\n2\n') |
| 114 | assert fourinarow.getPlayerMove('X', board) == (1, 5) |
| 115 | |
| 116 | |
| 117 | def test_displayBoard(capsys): |
nothing calls this directly
no outgoing calls
no test coverage detected