##// 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:

r2740:a7c52804
r2949:13751b1c
Show More
test_configurable.py
124 lines | 3.8 KiB | text/x-python | PythonLexer
/ IPython / config / tests / test_configurable.py
Brian Granger
First draft of refactored Component->Configurable.
r2731 #!/usr/bin/env python
# encoding: utf-8
"""
Tests for IPython.config.configurable
Authors:
* Brian Granger
* Fernando Perez (design help)
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2010 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
#-----------------------------------------------------------------------------
from unittest import TestCase
from IPython.config.configurable import Configurable, ConfigurableError
from IPython.utils.traitlets import (
TraitError, Int, Float, Str
)
from IPython.config.loader import Config
#-----------------------------------------------------------------------------
# Test cases
#-----------------------------------------------------------------------------
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 class MyConfigurable(Configurable):
a = Int(1, config=True)
b = Float(1.0, config=True)
c = Str('no config')
class Foo(Configurable):
a = Int(0, config=True)
b = Str('nope', config=True)
class Bar(Foo):
b = Str('gotit', config=False)
c = Float(config=True)
Brian Granger
First draft of refactored Component->Configurable.
r2731 class TestConfigurableConfig(TestCase):
def test_default(self):
c1 = Configurable()
c2 = Configurable(config=c1.config)
c3 = Configurable(config=c2.config)
self.assertEquals(c1.config, c2.config)
self.assertEquals(c2.config, c3.config)
def test_custom(self):
config = Config()
config.foo = 'foo'
config.bar = 'bar'
c1 = Configurable(config=config)
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 c2 = Configurable(config=c1.config)
c3 = Configurable(config=c2.config)
Brian Granger
First draft of refactored Component->Configurable.
r2731 self.assertEquals(c1.config, config)
self.assertEquals(c2.config, config)
self.assertEquals(c3.config, config)
# Test that copies are not made
self.assert_(c1.config is config)
self.assert_(c2.config is config)
self.assert_(c3.config is config)
self.assert_(c1.config is c2.config)
self.assert_(c2.config is c3.config)
def test_inheritance(self):
config = Config()
config.MyConfigurable.a = 2
config.MyConfigurable.b = 2.0
c1 = MyConfigurable(config=config)
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 c2 = MyConfigurable(config=c1.config)
Brian Granger
First draft of refactored Component->Configurable.
r2731 self.assertEquals(c1.a, config.MyConfigurable.a)
self.assertEquals(c1.b, config.MyConfigurable.b)
self.assertEquals(c2.a, config.MyConfigurable.a)
self.assertEquals(c2.b, config.MyConfigurable.b)
def test_parent(self):
config = Config()
config.Foo.a = 10
config.Foo.b = "wow"
config.Bar.b = 'later'
config.Bar.c = 100.0
f = Foo(config=config)
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 b = Bar(config=f.config)
Brian Granger
First draft of refactored Component->Configurable.
r2731 self.assertEquals(f.a, 10)
self.assertEquals(f.b, 'wow')
self.assertEquals(b.b, 'gotit')
self.assertEquals(b.c, 100.0)
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740
def test_override1(self):
config = Config()
config.MyConfigurable.a = 2
config.MyConfigurable.b = 2.0
c = MyConfigurable(a=3, config=config)
self.assertEquals(c.a, 3)
self.assertEquals(c.b, config.MyConfigurable.b)
self.assertEquals(c.c, 'no config')
def test_override2(self):
config = Config()
config.Foo.a = 1
config.Bar.b = 'or' # Up above b is config=False, so this won't do it.
config.Bar.c = 10.0
c = Bar(config=config)
self.assertEquals(c.a, config.Foo.a)
self.assertEquals(c.b, 'gotit')
self.assertEquals(c.c, config.Bar.c)
c = Bar(a=2, b='and', c=20.0, config=config)
self.assertEquals(c.a, 2)
self.assertEquals(c.b, 'and')
self.assertEquals(c.c, 20.0)