示例#1
0
    def test_collection_hierarchy_does_not_recurse_automatically(self):
        fred = self.Example('fred', 'flintstone')
        barney = self.Example('barney', 'rubble')
        wilma = self.Example('wilma', None)
        bambam = self.Example('bambam', None)
        guys = {'fred': None, 'barney': None}
        with bindings.BindingContext(auto_update=True) as outer:
            fred & 'val' > bindings.bind() > wilma
            with bindings.BindingContext(auto_update=False) as middle:
                barney & 'val' > bindings.bind() > bambam & 'val'
                with bindings.BindingContext(auto_update=False) as ctx:
                    fred > bindings.bind() > (guys, 'fred')  # default sources
                    barney > bindings.bind() > (guys, 'barney')

        assert wilma.val == 'flintstone'
        assert not bambam.val == 'rubble'
        assert not guys == {'fred': 'fred', 'barney': 'barney'}
示例#2
0
 def test_binding_collection_auto_update_suppress(self):
     fred = self.Example('fred', 'flintstone')
     barney = self.Example('barney', 'rubble')
     wilma = self.Example('wilma', None)
     bambam = self.Example('bambam', None)
     guys = {'fred': None, 'barney': None}
     with bindings.BindingContext(auto_update=False) as ctx:
         fred & 'val' > bindings.bind() > wilma  # default target
         barney & 'val' > bindings.bind() > bambam & 'val'
         fred > bindings.bind() > (guys, 'fred')  # default sources
         barney > bindings.bind() > (guys, 'barney')
     assert len(ctx.bindings) == 4
     assert wilma.val == None
     assert bambam.val == None
     assert guys == {'fred': None, 'barney': None}
示例#3
0
 def test_collection_deletes_bad_bindings(self):
     fred = self.Example('fred', 'flintstone')
     barney = self.Example('barney', 'rubble')
     wilma = self.Example('wilma', None)
     bambam = self.Example('bambam', None)
     guys = {'fred': None, 'barney': None}
     with bindings.BindingContext(False) as ctx:
         fred & 'val' > bindings.bind() > wilma  # default target
         barney & 'val' > bindings.bind() > bambam & 'val'
         fred > bindings.bind() > (guys, 'fred')  # default sources
         barney > bindings.bind() > (guys, 'barney')
         del (fred)  # delete referent invalidating 2 bindings
     ctx.update()
     assert len(ctx.bindings) == 2
     assert wilma.val is None
     assert guys['fred'] is None