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

Function test_main

tests/test_mancala.py:51–72  ·  view source on GitHub ↗
(capsys)

Source from the content-addressed store, hash-verified

49
50
51def test_main(capsys):
52 sys.stdin = io.StringIO('\nC\nD\nG\nC\nK\nI\nB\nH\nB\nJ\nD\nA\nI\nE\nH\nG\nJ\nF\nG\nH\nD\nI\nJ\nE\nH\nB\nG\n')
53 with pytest.raises(SystemExit):
54 mancala.main()
55 captured = capsys.readouterr()
56 assert 'Player 1 has won!' in captured.out
57
58
59 # Tests having so many seeds in a pocket that you skip the other player's store:
60 sys.stdin = io.StringIO('\nA\nG\nB\nH\nE\nI\nD\nG\nC\nH\nE\nF\nQUIT\n')
61 with pytest.raises(SystemExit):
62 mancala.main()
63 captured = capsys.readouterr()
64 assert '| 1 | 3 |' in captured.out
65
66
67 sys.stdin = io.StringIO('\nG\n1\n2\nC\nC\n\nQUIT\n')
68 with pytest.raises(SystemExit):
69 mancala.main()
70 captured = capsys.readouterr()
71 assert 'Please pick a letter on your side of the board.' in captured.out
72 assert 'Please pick a non-empty pit.' in captured.out

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected