Beispiel #1
0
def test_ask_for_value__interrupt_quits():
    """SystemExit should be raised if the user sends ^C."""

    with mock.patch.object(configure, "INPUT", side_effect=KeyboardInterrupt):
        with pytest.raises(SystemExit) as error:
            configure.ask_for_value("foo")
    assert error.value.args[0] == "Cancelled on user request"
Beispiel #2
0
def test_ask_for_value__interrupt_quits():
    """SystemExit should be raised if the user sends ^C."""

    with mock.patch.object(configure, "INPUT", side_effect=KeyboardInterrupt):
        with pytest.raises(SystemExit) as error:
            configure.ask_for_value("foo")
    assert error.value.args[0] == "Cancelled on user request"
Beispiel #3
0
def test_ask_for_value__empty_str_is_none():
    """If the user hits enter without input, None should be returned."""

    with mock.patch.object(configure, "INPUT", return_value=""):
        assert configure.ask_for_value("foo") is None
Beispiel #4
0
def test_ask_for_value():
    """Ensure we correctly prompt the user."""

    with mock.patch.object(configure, "INPUT", return_value="ok") as inp_patch:
        assert configure.ask_for_value("foo") == "ok"
    inp_patch.assert_called_once_with("Please enter the value for foo: ")
Beispiel #5
0
def test_ask_for_value__empty_str_is_none():
    """If the user hits enter without input, None should be returned."""

    with mock.patch.object(configure, "INPUT", return_value=""):
        assert configure.ask_for_value("foo") is None
Beispiel #6
0
def test_ask_for_value():
    """Ensure we correctly prompt the user."""

    with mock.patch.object(configure, "INPUT", return_value="ok") as inp_patch:
        assert configure.ask_for_value("foo") == "ok"
    inp_patch.assert_called_once_with("Please enter the value for foo: ")