##// END OF EJS Templates
The refactoring of the Task system is nearly complete. Now there are...
The refactoring of the Task system is nearly complete. Now there are multiple types of tasks including `StringTask` and `MapTask`. Each task type is responsible for running itself and processing its own result. This makes it much easier for people to create new task types. Also, the map and parallel function support has been completely refactored and improved. This includes a map and parallel function implementation for the task controller as well as a @parallel decorator.

File last commit:

r1244:ba669b1a
r1395:1feaf0a3
Show More
test_newserialized.py
101 lines | 3.7 KiB | text/x-python | PythonLexer
/ IPython / kernel / tests / test_newserialized.py
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234 # encoding: utf-8
"""This file contains unittests for the shell.py module."""
__docformat__ = "restructuredtext en"
#-------------------------------------------------------------------------------
# Copyright (C) 2008 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Imports
#-------------------------------------------------------------------------------
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 try:
import zope.interface as zi
from twisted.trial import unittest
from IPython.testing.util import DeferredTestCase
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 from IPython.kernel.newserialized import \
ISerialized, \
IUnSerialized, \
Serialized, \
UnSerialized, \
SerializeIt, \
UnSerializeIt
except ImportError:
pass
else:
#-------------------------------------------------------------------------------
# Tests
#-------------------------------------------------------------------------------
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 class SerializedTestCase(unittest.TestCase):
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 def setUp(self):
pass
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 def tearDown(self):
pass
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 def testSerializedInterfaces(self):
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 us = UnSerialized({'a':10, 'b':range(10)})
s = ISerialized(us)
uss = IUnSerialized(s)
self.assert_(ISerialized.providedBy(s))
self.assert_(IUnSerialized.providedBy(us))
self.assert_(IUnSerialized.providedBy(uss))
for m in list(ISerialized):
self.assert_(hasattr(s, m))
for m in list(IUnSerialized):
self.assert_(hasattr(us, m))
for m in list(IUnSerialized):
self.assert_(hasattr(uss, m))
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 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())
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian E Granger
Finished initial reworking and updating of setup.py and friends, including the MANIFEST.in. Everything seems...
r1244 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)
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234