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

Function test_getMove

tests/test_blackjack.py:152–179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150
151
152def test_getMove():
153 playerHand = [('A', blackjack.HEARTS), ('K', blackjack.HEARTS)]
154
155 # Test basic stand:
156 sys.stdin = io.StringIO('S\n')
157 assert blackjack.getMove(playerHand, 100) == 'S'
158 sys.stdin = io.StringIO('s\n')
159 assert blackjack.getMove(playerHand, 100) == 'S'
160
161 # Test basic hit:
162 sys.stdin = io.StringIO('H\n')
163 assert blackjack.getMove(playerHand, 100) == 'H'
164 sys.stdin = io.StringIO('h\n')
165 assert blackjack.getMove(playerHand, 100) == 'H'
166
167 # Test basic double down:
168 sys.stdin = io.StringIO('D\n')
169 assert blackjack.getMove(playerHand, 100) == 'D'
170 sys.stdin = io.StringIO('d\n')
171 assert blackjack.getMove(playerHand, 100) == 'D'
172
173 # Test basic double down that's not available, so stand:
174 sys.stdin = io.StringIO('D\nH\n')
175 assert blackjack.getMove(playerHand + playerHand, 100) == 'H'
176
177 # Test double down but player doesn't have any money:
178 sys.stdin = io.StringIO('D\nH\n')
179 assert blackjack.getMove(playerHand, 0) == 'H'
180
181
182def test_main(capsys):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected