Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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))
Exemplo n.º 3
0
 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))
Exemplo n.º 4
0
    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)