def test_default_boolean_input(monkeypatch: MonkeyPatch) -> None: monkeypatch.setattr("sys.stdin", io.StringIO("\n")) assert quickstart.input_or_default("Hello", "N", quickstart.boolean) is False
def test_bad_then_good_boolean_input_false(monkeypatch: MonkeyPatch) -> None: monkeypatch.setattr("sys.stdin", io.StringIO("pouette\nn")) assert quickstart.input_or_default("Hello", "N", quickstart.boolean) is False
def test_2nd_time(monkeypatch: MonkeyPatch) -> None: monkeypatch.setattr("sys.stdin", io.StringIO("youpi\nyes")) assert quickstart.input_or_default("Say yes?", validator=quickstart.boolean) is True
def test_invalid_default_value() -> None: with pytest.raises(ValueError): quickstart.input_or_default( "Give a bool", "not a bool", validator=quickstart.boolean )
def test_input(monkeypatch: MonkeyPatch) -> None: monkeypatch.setattr("sys.stdin", io.StringIO("youpi")) assert quickstart.input_or_default("Say youpi?") == "youpi"