Exemple #1
0
def test_query_user_defaults_dict_corrupt(monkeypatch):
    monkeypatch.setattr(
        'builtins.input',
        lambda description: USER_INPUT_GENERIC,
    )
    with pytest.raises(TypeError):
        GetParams.query_user(d=DEFAULTS_DICT_CORRUPT, )
Exemple #2
0
def test_query_user_raise_keyboard_interrupt(monkeypatch):
    monkeypatch.setattr(
        'builtins.input',
        lambda description: (_ for _ in ()).throw(KeyboardInterrupt),
    )
    with pytest.raises(KeyboardInterrupt):
        GetParams.query_user(d=DEFAULTS_DICT_GENERIC, )
Exemple #3
0
def test_query_user_no_args(monkeypatch):
    monkeypatch.setattr(
        'builtins.input',
        lambda description: USER_INPUT_GENERIC,
    )
    with pytest.raises(TypeError):
        GetParams.query_user()
Exemple #4
0
def test_query_user_defaults_dict_choices_multi_wrong_input(monkeypatch):
    monkeypatch.setattr(
        'builtins.input',
        lambda description: USER_INPUT_CHOICES_INVALID,
    )
    with pytest.raises(ValueError):
        GetParams.query_user(
            d=DEFAULTS_DICT_CHOICES_MULTI,
            retries=RETRIES,
        ) == USER_INPUT_CHOICES
Exemple #5
0
def test_query_user_defaults_dict_choices_no_alt(monkeypatch):
    monkeypatch.setattr(
        'builtins.input',
        lambda description: USER_INPUT_CHOICES,
    )
    assert GetParams.query_user(
        d=DEFAULTS_DICT_CHOICES_NO_ALT) == USER_INPUT_CHOICES
Exemple #6
0
def test_query_user_defaults_dict_generic_no_input(monkeypatch):
    monkeypatch.setattr(
        'builtins.input',
        lambda description: "",
    )
    assert GetParams.query_user(
        d=DEFAULTS_DICT_GENERIC, ) == DEFAULTS_DICT_GENERIC['value']
Exemple #7
0
def test_query_user_defaults_dict_generic(monkeypatch):
    monkeypatch.setattr(
        'builtins.input',
        lambda description: USER_INPUT_GENERIC,
    )
    assert GetParams.query_user(
        d=DEFAULTS_DICT_GENERIC, ) == USER_INPUT_GENERIC
Exemple #8
0
def test_query_user_wrong_type_retries():
    with pytest.raises(TypeError):
        GetParams.query_user(
            d=DEFAULTS_DICT_CORRUPT,
            retries=LIST,
        )
Exemple #9
0
def test_query_user_wrong_type_d():
    with pytest.raises(TypeError):
        GetParams.query_user(d=LIST, )