Пример #1
0
 def test_invalid_binding_fails(self):
     ex = self.Example('fred', 'flintstone')
     ex2 = self.Example('barney', 'rubble')
     tester = bindings.Binding(bindings.get_accessor(ex, 'name'),
                               bindings.get_accessor(ex2, 'val'))
     tester.invalidate()
     assert not tester()
Пример #2
0
 def test_binding_source_order(self):
     ex = self.Example('fred', 'flintstone')
     ex2 = self.Example('barney', 'rubble')
     tester = bindings.Binding(bindings.get_accessor(ex, 'name'),
                               bindings.get_accessor(ex2, 'val'))
     assert tester.getter.target.name == 'fred'
     assert tester.setter.target.name == 'barney'
Пример #3
0
 def test_basic_binding_update(self):
     ex = self.Example('fred', 'flintstone')
     ex2 = self.Example('barney', 'rubble')
     tester = bindings.Binding(bindings.get_accessor(ex, 'name'),
                               bindings.get_accessor(ex2, 'val'))
     tester()
     assert ex2.val == ex.name
Пример #4
0
 def test_binding_survives_object_deletion(self):
     ex = self.Example('fred', 'flintstone')
     ex2 = self.Example('barney', 'rubble')
     tester = bindings.Binding(bindings.get_accessor(ex, 'name'),
                               bindings.get_accessor(ex2, 'val'))
     del (ex)
     assert not tester()  # deleted referent = failed binding
     assert ex2.val == 'rubble'  # so value is unchanged
Пример #5
0
 def test_bindings_except_when_allowed(self):
     ex = self.Example('fred', 'flintstone')
     ex2 = self.Example('barney', 'rubble')
     tester = bindings.Binding(bindings.get_accessor(ex, 'name'),
                               bindings.get_accessor(ex2, 'val'))
     bindings.BREAK_ON_ACCESS_FAILURE = True
     bindings.BREAK_ON_BIND_FAILURE = True
     del (ex)
     self.assertRaises(bindings.BindingError, tester)
Пример #6
0
 def test_binding_excepts_on_bad_arguments(self):
     self.assertRaises(bindings.BindingError,
                       lambda: bindings.Binding(None, None))