mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 23:26:40 -08:00
Bug (Python): Refactoring
- Rename files to follow PEP8 convention / make them testable - Add type annotations - Fix Flake8 issues - Variable naming - Add unit test
This commit is contained in:
25
16_Bug/python/test_bug.py
Normal file
25
16_Bug/python/test_bug.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user