예제 #1
0
    def test_check_value_choice_of_one_with_none(self):
        subname = "testArg"
        subtypes = check.ChoiceOfOne([int, type(None)])
        subvalues = {"int": ">0", "NoneType": None}
        subarg = None

        check.check_value(subname, subtypes, subvalues, subarg)
예제 #2
0
    def test_check_value_choice_of_one_with_object(self):
        subname = "testArg"
        subtypes = check.ChoiceOfOne([int, TestObj])
        subvalues = {"int": ">0", "test_check.TestObj": None}
        subarg = TestObj()

        check.check_value(subname, subtypes, subvalues, subarg)
예제 #3
0
    def test_check_value_choice_of_one(self):
        subname = "testArg"
        subtypes = check.ChoiceOfOne([int, float])
        subvalues = {"int": ">0", "float": "<0"}
        subarg = 1

        check.check_value(subname, subtypes, subvalues, subarg)
예제 #4
0
 def test_type_choice_of_one_fail(self):
     try:
         check.check_subtype("testArg", check.ChoiceOfOne([int, float]),
                             "string")
     except AssertionError:
         pass
     else:
         self.fail("should have thrown AssertionError")
예제 #5
0
    def test_check_value_choice_of_one_fail(self):
        subname = "testArg"
        subtypes = check.ChoiceOfOne([int, float])
        subvalues = {"int": ">0", "float": "<0"}
        subarg = 50.3  # is float, but >0

        try:
            check.check_value(subname, subtypes, subvalues, subarg)
        except AssertionError:
            pass
        else:
            self.fail("should have thrown AssertionError")
예제 #6
0
 def test_type_choice_of_one_with_none(self):
     check.check_subtype("testArg",
                         check.ChoiceOfOne([int, float,
                                            type(None)]), None)
예제 #7
0
 def test_type_choice_of_one_object(self):
     obj = TestObj()
     self.assertEqual(
         check.check_subtype("testArg", check.ChoiceOfOne([int, TestObj]),
                             obj), obj)
예제 #8
0
 def test_type_choice_of_one(self):
     self.assertEqual(
         check.check_subtype("testArg", check.ChoiceOfOne([int, float]),
                             58.1), 58.1)
예제 #9
0
 def test_choice_of_one_with_object(self):
     self.assertEqual(
         check.eval_subtype("one([int, cls('test_check.TestObj')])"),
         check.ChoiceOfOne([int, TestObj]))
예제 #10
0
 def test_type_choice(self):
     self.assertEqual(check.eval_subtype("one([int, float])"),
                      check.ChoiceOfOne([int, float]))