mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
- Rename files to follow PEP8 convention / make them testable - Add type annotations - Fix Flake8 issues - Variable naming - Add unit test
26 lines
626 B
Python
26 lines
626 B
Python
import io
|
|
from typing import Callable
|
|
|
|
import pytest
|
|
from _pytest.monkeypatch import MonkeyPatch
|
|
|
|
from bug import main
|
|
from bug_overengineered import main as overengineered_main
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"main",
|
|
[main, overengineered_main],
|
|
)
|
|
def test_main(monkeypatch: MonkeyPatch, main: Callable[[], None]) -> None:
|
|
monkeypatch.setattr("time.sleep", lambda n: n)
|
|
instructions = "Y"
|
|
pictures = "Y"
|
|
monkeypatch.setattr(
|
|
"sys.stdin",
|
|
io.StringIO(
|
|
f"{instructions}\n{pictures}\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\nN\n"
|
|
),
|
|
)
|
|
main()
|