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")
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")
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")
def test_type_choice_of_one_with_none(self): check.check_subtype("testArg", check.ChoiceOfOne([int, float, type(None)]), None)
def test_type_choice_of_one_object(self): obj = TestObj() self.assertEqual( check.check_subtype("testArg", check.ChoiceOfOne([int, TestObj]), obj), obj)
def test_type_choice_of_one(self): self.assertEqual( check.check_subtype("testArg", check.ChoiceOfOne([int, float]), 58.1), 58.1)
def test_type_native_cast(self): self.assertEqual( check.check_subtype("testArg", int, "10", should_cast=True), 10)
def test_type_native_no_cast(self): self.assertEqual(check.check_subtype("testArg", int, 10), 10)