def testAnonymousCategoryType(self): # Root x argument = CategoryParameter(CategoryType("Root"), "x") argument.register(self.context) st = argument.getType(self.context) self.assertIsInstance(st, CategoryType) self.assertFalse( st.isAssignableFrom(self.context, BooleanType.instance)) self.assertFalse( st.isAssignableFrom(self.context, IntegerType.instance)) self.assertFalse( st.isAssignableFrom(self.context, DecimalType.instance)) self.assertFalse(st.isAssignableFrom(self.context, TextType.instance)) self.assertFalse(st.isAssignableFrom(self.context, DateType.instance)) self.assertFalse( st.isAssignableFrom(self.context, DateTimeType.instance)) self.assertFalse( st.isAssignableFrom(self.context, MissingType.instance)) self.assertFalse(st.isAssignableFrom( self.context, AnyType.instance)) # any type never compatible self.assertFalse( st.isAssignableFrom( self.context, CategoryType("Simple"))) # since Simple does not extend Root self.assertTrue(st.isAssignableFrom( self.context, CategoryType("Root"))) # since Root is Root self.assertTrue( st.isAssignableFrom(self.context, CategoryType( "DerivedWithOther"))) # since DerivedWithOther extends Root self.assertTrue( st.isAssignableFrom(self.context, CategoryType( "DerivedWithName"))) # since DerivedWithName extends Root
def testAnonymousAnyType(self): # any x argument = CategoryParameter(AnyType.instance, "x") argument.register(self.context) st = argument.getType(self.context) self.assertIsInstance(st, AnyType) self.assertTrue(st.isAssignableFrom(self.context, BooleanType.instance)) self.assertTrue(st.isAssignableFrom(self.context, IntegerType.instance)) self.assertTrue(st.isAssignableFrom(self.context, DecimalType.instance)) self.assertTrue(st.isAssignableFrom(self.context, TextType.instance)) self.assertTrue(st.isAssignableFrom(self.context, DateType.instance)) self.assertTrue( st.isAssignableFrom(self.context, DateTimeType.instance)) self.assertTrue(st.isAssignableFrom( self.context, MissingType.instance)) # missing type always compatible self.assertTrue(st.isAssignableFrom(self.context, AnyType.instance)) self.assertTrue( st.isAssignableFrom(self.context, CategoryType("Simple"))) self.assertTrue(st.isAssignableFrom(self.context, CategoryType("Root"))) self.assertTrue( st.isAssignableFrom(self.context, CategoryType("DerivedWithOther"))) self.assertTrue( st.isAssignableFrom(self.context, CategoryType("DerivedWithName")))