Step 1
TirSystem/github-action: Sync GitHub mirror metadata / sync-metadata (push) Successful in 6s

Picking a random word and checking answers
This commit is contained in:
2026-10-04 12:31:58 +08:00
commit f07c34a5fa
12 changed files with 530 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
from hangman import main as cli
def run(monkeypatch, capsys, word, letter):
monkeypatch.setattr(cli, "choose_word", lambda: word)
monkeypatch.setattr("builtins.input", lambda _="": letter)
cli.main()
return capsys.readouterr().out
def test_right_guess(monkeypatch, capsys):
assert "Right" in run(monkeypatch, capsys, "camel", "a")
def test_wrong_guess(monkeypatch, capsys):
assert "Wrong" in run(monkeypatch, capsys, "camel", "z")