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

Function test_getBet

tests/test_blackjack.py:111–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109
110
111def test_getBet():
112 # Basic test:
113 sys.stdin = io.StringIO('50\n')
114 assert blackjack.getBet(100) == 50
115
116 sys.stdin = io.StringIO(' 50 \n')
117 assert blackjack.getBet(100) == 50
118
119 # Test quitting:
120 with pytest.raises(SystemExit):
121 sys.stdin = io.StringIO('QUIT\n')
122 blackjack.getBet(100)
123
124 with pytest.raises(SystemExit):
125 sys.stdin = io.StringIO('quit\n')
126 blackjack.getBet(100)
127
128 with pytest.raises(SystemExit):
129 sys.stdin = io.StringIO('qUiT\n')
130 blackjack.getBet(100)
131
132 with pytest.raises(SystemExit):
133 sys.stdin = io.StringIO(' quit \n')
134 blackjack.getBet(100)
135
136 # Test bad input:
137 sys.stdin = io.StringIO('invalid\n50\n')
138 assert blackjack.getBet(100) == 50
139
140 # Test bet that is too high:
141 sys.stdin = io.StringIO('101\n50\n')
142 assert blackjack.getBet(100) == 50
143
144
145def test_pause(capsys):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected