예제 #1
0
 def test_bad_root(self):
     c1 = Component(None)
     c2 = Component(None)
     c3 = Component(None)
     self.assertRaises(ComponentError, setattr, c1, 'root', c2)
     c1.parent = c2
     self.assertEquals(c1.root, c2)
     self.assertRaises(ComponentError, setattr, c1, 'root', c3)
예제 #2
0
 def test_bad_root(self):
     c1 = Component(None)
     c2 = Component(None)
     c3 = Component(None)
     self.assertRaises(ComponentError, setattr, c1, 'root', c2)
     c1.parent = c2
     self.assertEquals(c1.root, c2)
     self.assertRaises(ComponentError, setattr, c1, 'root', c3)
예제 #3
0
 def test_root(self):
     c1 = Component(None)
     c2 = Component(c1)
     c3 = Component(c1)
     c4 = Component(c3)
     self.assertEquals(c1.root, c1.root)
     self.assertEquals(c2.root, c1)
     self.assertEquals(c3.root, c1)
     self.assertEquals(c4.root, c1)
예제 #4
0
    def test_default(self):
        class MyComponent(Component):
            pass

        c1 = Component(None)
        c2 = MyComponent(None)
        c3 = Component(c2)
        self.assertNotEquals(c1.name, c2.name)
        self.assertNotEquals(c1.name, c3.name)
예제 #5
0
    def test_manual(self):
        class MyComponent(Component):
            pass

        c1 = Component(None, name='foo')
        c2 = MyComponent(None, name='bar')
        c3 = Component(c2, name='bah')
        self.assertEquals(c1.name, 'foo')
        self.assertEquals(c2.name, 'bar')
        self.assertEquals(c3.name, 'bah')
예제 #6
0
    def test_subclass_parent(self):
        c1 = Component(None)
        self.assertRaises(TraitletError, setattr, c1, 'parent', 10)

        class MyComponent(Component):
            pass

        c1 = Component(None)
        c2 = MyComponent(c1)
        self.assertEquals(MyComponent.parent.this_class, Component)
        self.assertEquals(c2.parent, c1)
예제 #7
0
 def test_change_parent(self):
     c1 = Component(None)
     c2 = Component(None)
     c3 = Component(c1)
     self.assertEquals(c3.root, c1)
     self.assertEquals(c3.parent, c1)
     self.assertEquals(c1.children,[c3])
     c3.parent = c2
     self.assertEquals(c3.root, c2)
     self.assertEquals(c3.parent, c2)
     self.assertEquals(c2.children,[c3])
     self.assertEquals(c1.children,[])
예제 #8
0
 def test_change_parent(self):
     c1 = Component(None)
     c2 = Component(None)
     c3 = Component(c1)
     self.assertEquals(c3.root, c1)
     self.assertEquals(c3.parent, c1)
     self.assertEquals(c1.children, [c3])
     c3.parent = c2
     self.assertEquals(c3.root, c2)
     self.assertEquals(c3.parent, c2)
     self.assertEquals(c2.children, [c3])
     self.assertEquals(c1.children, [])
예제 #9
0
 def test_parent_child(self):
     c1 = Component(None)
     c2 = Component(c1)
     c3 = Component(c1)
     c4 = Component(c3)
     self.assertEquals(c1.parent, None)
     self.assertEquals(c2.parent, c1)
     self.assertEquals(c3.parent, c1)
     self.assertEquals(c4.parent, c3)
     self.assertEquals(c1.children, [c2, c3])
     self.assertEquals(c2.children, [])
     self.assertEquals(c3.children, [c4])
     self.assertEquals(c4.children, [])
예제 #10
0
 def test_custom(self):
     config = Config()
     config.foo = 'foo'
     config.bar = 'bar'
     c1 = Component(None, config=config)
     c2 = Component(c1)
     c3 = Component(c2)
     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)
예제 #11
0
 def shell(self):
     return Component.get_instances(root=self.root, klass="IPython.core.iplib.InteractiveShell")[0]
예제 #12
0
 def shell(self):
     return Component.get_instances(
         root=self.root, klass='IPython.core.iplib.InteractiveShell')[0]
예제 #13
0
 def test_default(self):
     c1 = Component(None)
     c2 = Component(c1)
     c3 = Component(c2)
     self.assertEquals(c1.config, c2.config)
     self.assertEquals(c2.config, c3.config)