##// END OF EJS Templates
Added GTK support to ZeroMQ kernel....
Added GTK support to ZeroMQ kernel. We use an approach which is a combination of an gtk timer callback into our execution loop, like we do for Qt and Wx, I've run as tests several GTK examples found on the net, as well as multiple matplotlib scripts, and so far everything works as expected. The only catch is that we silently trap gtk.main_quit(), so examples that call it with a 'close' button or similar seem to not do anything. But their windows close normally and no other problems have been found. This solution uses code taken from an old bug report of ours: https://bugs.launchpad.net/ipython/+bug/270856 specifically the attachment in this comment: https://bugs.launchpad.net/ipython/+bug/270856/comments/6 along with the changes suggested by Michiel de Hoon there. Thanks to Ville and Michiel for that old discussion, which put me on the right track to figure out the details of the logic needed for GTK.

File last commit:

r1960:51f38f50
r2949:13751b1c
Show More
test_newserialized.py
102 lines | 3.4 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"
Brian Granger
Fix for ipcluster bug: https://bugs.launchpad.net/bugs/358202...
r1944 #-----------------------------------------------------------------------------
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234 # 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.
Brian Granger
Fix for ipcluster bug: https://bugs.launchpad.net/bugs/358202...
r1944 #-----------------------------------------------------------------------------
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian Granger
Fix for ipcluster bug: https://bugs.launchpad.net/bugs/358202...
r1944 #-----------------------------------------------------------------------------
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234 # Imports
Brian Granger
Fix for ipcluster bug: https://bugs.launchpad.net/bugs/358202...
r1944 #-----------------------------------------------------------------------------
Brian E Granger
This is a manual merge of certain things in the ipython1-dev branch, revision 46, into the main ...
r1234
Brian Granger
Fixing misc testing related things.
r1960 # Tell nose to skip this module
__test__ = {}
import zope.interface as zi
from twisted.trial import unittest
from IPython.testing.util import DeferredTestCase
from IPython.kernel.newserialized import \
ISerialized, \
IUnSerialized, \
Serialized, \
UnSerialized, \
SerializeIt, \
UnSerializeIt
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555
Brian Granger
Fix for ipcluster bug: https://bugs.launchpad.net/bugs/358202...
r1944 #-----------------------------------------------------------------------------
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 # Tests
Brian Granger
Fix for ipcluster bug: https://bugs.launchpad.net/bugs/358202...
r1944 #-----------------------------------------------------------------------------
Brian Granger
Removed some tabs and added a new way of skipping tests that have...
r1555
class SerializedTestCase(unittest.TestCase):
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 Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 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 Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 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 Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 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 Granger
Removed some tabs and added a new way of skipping tests that have...
r1555 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())
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