def test_getbool__with_unknown_param_returns_default_value(self): userdata = UserData() value = userdata.getint("param", 1.2) assert isinstance(value, float) self.assertEqual(value, 1.2)
def test_getint__with_known_param_and_valid_text(self): userdata = UserData(param="42") value = userdata.getint("param") assert isinstance(value, int) self.assertEqual(value, 42)
def test_getint__with_unknown_param_without_default_returns_zero(self): userdata = UserData() value = userdata.getint("param") self.assertEqual(value, 0)
def test_getint__with_unknown_param_returns_default_value(self): userdata = UserData() value = userdata.getint("param", 123) assert isinstance(value, int) assert value == 123
def test_getint__with_known_param_and_invalid_text_raises_ValueError(self): userdata = UserData(param="__BAD_NUMBER__") with pytest.raises(ValueError): userdata.getint("param")