MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / test_displayBoard

Function test_displayBoard

tests/test_fourinarow.py:117–155  ·  view source on GitHub ↗
(capsys)

Source from the content-addressed store, hash-verified

115
116
117def test_displayBoard(capsys):
118 board = fourinarow.getNewBoard()
119 fourinarow.displayBoard(board)
120 captured = capsys.readouterr()
121 assert ' 1234567\n' + \
122 ' +-------+\n' + \
123 ' |.......|\n' + \
124 ' |.......|\n' + \
125 ' |.......|\n' + \
126 ' |.......|\n' + \
127 ' |.......|\n' + \
128 ' |.......|\n' + \
129 ' +-------+\n' in captured.out
130
131 board[(0, 5)] = 'X'
132 fourinarow.displayBoard(board)
133 captured = capsys.readouterr()
134 assert ' 1234567\n' + \
135 ' +-------+\n' + \
136 ' |.......|\n' + \
137 ' |.......|\n' + \
138 ' |.......|\n' + \
139 ' |.......|\n' + \
140 ' |.......|\n' + \
141 ' |X......|\n' + \
142 ' +-------+\n' in captured.out
143
144 board[(1, 5)] = 'O'
145 fourinarow.displayBoard(board)
146 captured = capsys.readouterr()
147 assert ' 1234567\n' + \
148 ' +-------+\n' + \
149 ' |.......|\n' + \
150 ' |.......|\n' + \
151 ' |.......|\n' + \
152 ' |.......|\n' + \
153 ' |.......|\n' + \
154 ' |XO.....|\n' + \
155 ' +-------+\n' in captured.out
156
157def test_main(capsys):
158 # Test a game where X wins:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected