Example #1
0
 def test_type_native_cast_fail(self):
     try:
         check.check_subtype("testArg", int, "string", should_cast=True)
     except ValueError:
         # successful failure
         pass
     else:
         self.fail("should have thrown ValueError")
Example #2
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")
Example #3
0
 def test_type_native_no_cast_fail(self):
     try:
         check.check_subtype("testArg", int, "string")
     except AssertionError:
         # successful failure.... oxymoron
         pass
     else:
         self.fail("should have thrown AssertionError")
Example #4
0
 def test_type_choice_of_one_with_none(self):
     check.check_subtype("testArg",
                         check.ChoiceOfOne([int, float,
                                            type(None)]), None)
Example #5
0
 def test_type_choice_of_one_object(self):
     obj = TestObj()
     self.assertEqual(
         check.check_subtype("testArg", check.ChoiceOfOne([int, TestObj]),
                             obj), obj)
Example #6
0
 def test_type_choice_of_one(self):
     self.assertEqual(
         check.check_subtype("testArg", check.ChoiceOfOne([int, float]),
                             58.1), 58.1)
Example #7
0
 def test_type_native_cast(self):
     self.assertEqual(
         check.check_subtype("testArg", int, "10", should_cast=True), 10)
Example #8
0
 def test_type_native_no_cast(self):
     self.assertEqual(check.check_subtype("testArg", int, 10), 10)