Exemplo n.º 1
0
 def testPickleSerialized(self):
     obj = {'a':1.45345, 'b':'asdfsdf', 'c':10000}
     original = UnSerialized(obj)
     originalSer = ISerialized(original)
     firstData = originalSer.getData()
     firstTD = originalSer.getTypeDescriptor()
     firstMD = originalSer.getMetadata()
     self.assert_(firstTD == 'pickle')
     self.assert_(firstMD == {})
     unSerialized = IUnSerialized(originalSer)
     secondObj = unSerialized.getObject()
     for k, v in secondObj.items():
         self.assert_(obj[k] == v)
     secondSer = ISerialized(UnSerialized(secondObj))
     self.assert_(firstData == secondSer.getData())
     self.assert_(firstTD == secondSer.getTypeDescriptor() )
     self.assert_(firstMD == secondSer.getMetadata())
Exemplo n.º 2
0
 def testPickleSerialized(self):
     obj = {'a': 1.45345, 'b': 'asdfsdf', 'c': 10000L}
     original = UnSerialized(obj)
     originalSer = ISerialized(original)
     firstData = originalSer.getData()
     firstTD = originalSer.getTypeDescriptor()
     firstMD = originalSer.getMetadata()
     self.assert_(firstTD == 'pickle')
     self.assert_(firstMD == {})
     unSerialized = IUnSerialized(originalSer)
     secondObj = unSerialized.getObject()
     for k, v in secondObj.iteritems():
         self.assert_(obj[k] == v)
     secondSer = ISerialized(UnSerialized(secondObj))
     self.assert_(firstData == secondSer.getData())
     self.assert_(firstTD == secondSer.getTypeDescriptor())
     self.assert_(firstMD == secondSer.getMetadata())
Exemplo n.º 3
0
 def testNDArraySerialized(self):
     try:
         import numpy
     except ImportError:
         pass
     else:
         a = numpy.linspace(0.0, 1.0, 1000)
         unSer1 = UnSerialized(a)
         ser1 = ISerialized(unSer1)
         td = ser1.getTypeDescriptor()
         self.assert_(td == 'ndarray')
         md = ser1.getMetadata()
         self.assert_(md['shape'] == a.shape)
         self.assert_(md['dtype'] == a.dtype.str)
         buff = ser1.getData()
         self.assert_(buff == numpy.getbuffer(a))
         s = Serialized(buff, td, md)
         us = IUnSerialized(s)
         final = us.getObject()
         self.assert_(numpy.getbuffer(a) == numpy.getbuffer(final))
         self.assert_(a.dtype.str == final.dtype.str)
         self.assert_(a.shape == final.shape)
Exemplo n.º 4
0
 def testNDArraySerialized(self):
     try:
         import numpy
     except ImportError:
         pass
     else:
         a = numpy.linspace(0.0, 1.0, 1000)
         unSer1 = UnSerialized(a)
         ser1 = ISerialized(unSer1)
         td = ser1.getTypeDescriptor()
         self.assert_(td == 'ndarray')
         md = ser1.getMetadata()
         self.assert_(md['shape'] == a.shape)
         self.assert_(md['dtype'] == a.dtype.str)
         buff = ser1.getData()
         self.assert_(buff == numpy.getbuffer(a))
         s = Serialized(buff, td, md)
         us = IUnSerialized(s)
         final = us.getObject()
         self.assert_(numpy.getbuffer(a) == numpy.getbuffer(final))
         self.assert_(a.dtype.str == final.dtype.str)
         self.assert_(a.shape == final.shape)