def test_getbool__with_known_param_and_valid_text(self): for true_text in ["true", "TRUE", "True", "yes", "on", "1"]: userdata = UserData(param=true_text) value = userdata.getbool("param") assert isinstance(value, bool), "text=%s" % true_text self.assertEqual(value, True) for false_text in ["false", "FALSE", "False", "no", "off", "0"]: userdata = UserData(param=false_text) value = userdata.getbool("param") assert isinstance(value, bool), "text=%s" % false_text self.assertEqual(value, False)
def test_getbool__with_known_param_and_valid_text(self): for true_text in ["true", "TRUE", "True", "yes", "on", "1"]: userdata = UserData(param=true_text) value = userdata.getbool("param") assert isinstance(value, bool), "text=%s" % true_text self.assertEqual(value, True) for false_text in ["false", "FALSE", "False", "no", "off", "0"]: userdata = UserData(param=false_text) value = userdata.getbool("param") assert isinstance(value, bool), "text=%s" % false_text self.assertEqual(value, False)
def test_getbool__with_known_param_and_invalid_text_raises_ValueError( self): userdata = UserData(param="__BAD_VALUE__") with pytest.raises(ValueError): userdata.getbool("param")
def test_getbool__with_known_param_and_valid_false_text(self, text): false_text = text userdata = UserData(param=false_text) value = userdata.getbool("param") assert isinstance(value, bool), "text=%s" % false_text assert value is False
def test_getbool__with_known_param_and_invalid_text_raises_ValueError(self): userdata = UserData(param="__BAD_VALUE__") with pytest.raises(ValueError): userdata.getbool("param")
def test_getbool__with_known_param_and_valid_false_text(self, text): false_text = text userdata = UserData(param=false_text) value = userdata.getbool("param") assert isinstance(value, bool), "text=%s" % false_text assert value is False