mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-21 23:00:43 -08:00
24 lines
622 B
Python
24 lines
622 B
Python
import io
|
|
from unittest import mock
|
|
|
|
from acey_ducey import play_game
|
|
|
|
|
|
@mock.patch("random.shuffle")
|
|
def test_play_game_lose(mock_random_shuffle, monkeypatch, capsys) -> None:
|
|
monkeypatch.setattr("sys.stdin", io.StringIO("100\n100"))
|
|
|
|
def identity(x):
|
|
return x
|
|
|
|
mock_random_shuffle = identity # noqa: F841
|
|
play_game()
|
|
captured = capsys.readouterr()
|
|
assert captured.out == (
|
|
"You now have 100 dollars\n\n"
|
|
"Here are you next two cards\n King\n Ace\n\n"
|
|
"What is your bet? Queen\n"
|
|
"Sorry, you lose\n"
|
|
"Sorry, friend, but you blew your wad\n"
|
|
)
|