Пример #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"
Пример #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"
Пример #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
Пример #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: ")
Пример #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
Пример #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: ")