예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
 def test_getbool__with_known_param_and_invalid_text_raises_ValueError(
         self):
     userdata = UserData(param="__BAD_VALUE__")
     with pytest.raises(ValueError):
         userdata.getbool("param")
예제 #4
0
 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
예제 #5
0
 def test_getbool__with_known_param_and_invalid_text_raises_ValueError(self):
     userdata = UserData(param="__BAD_VALUE__")
     with pytest.raises(ValueError):
         userdata.getbool("param")
예제 #6
0
 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