def test_basetype_serialize(self): ls = [ int, str, bool, float, list, tuple, sample.Sample, agent.Agent, ] for typ in ls: val = type_to_node(typ) typ2 = node_to_type(val) self.assertEqual(typ, typ2) ls = [ (long, int), (unicode, str), (builtin.NullAgent, agent.Agent), (sample.MixinSample, sample.Sample), ] for (typ, restyp) in ls: val = type_to_node(typ) typ2 = node_to_type(val) self.assertEqual(restyp, typ2)
def test_wrapped_serialize(self): typ = Wrapped(int) val = type_to_node(typ) typ2 = node_to_type(val) self.assert_(isinstance(typ2, Wrapped)) self.assertEqual(typ2.type, int) typ = Wrapped(ListOf(int, bool)) val = type_to_node(typ) typ2 = node_to_type(val) self.assert_(isinstance(typ2, Wrapped)) self.assert_(isinstance(typ2.type, ListOf)) self.assertEqual(typ2.type.types, (int, bool))
def test_basetype_serialize(self): ls = [ int, str, bool, float, list, tuple, sample.Sample, agent.Agent, ] for typ in ls: val = type_to_node(typ) typ2 = node_to_type(val) self.assertEqual(typ, typ2) ls = [ (long,int), (unicode,str), (builtin.NullAgent, agent.Agent), (sample.MixinSample, sample.Sample), ] for (typ, restyp) in ls: val = type_to_node(typ) typ2 = node_to_type(val) self.assertEqual(restyp, typ2)