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, )
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, )
def test_query_user_no_args(monkeypatch): monkeypatch.setattr( 'builtins.input', lambda description: USER_INPUT_GENERIC, ) with pytest.raises(TypeError): GetParams.query_user()
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
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
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']
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
def test_query_user_wrong_type_retries(): with pytest.raises(TypeError): GetParams.query_user( d=DEFAULTS_DICT_CORRUPT, retries=LIST, )
def test_query_user_wrong_type_d(): with pytest.raises(TypeError): GetParams.query_user(d=LIST, )