Exemplo n.º 1
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
Exemplo n.º 2
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()
Exemplo n.º 3
0
 def test_pyattr_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube.rx)
     assert isinstance(ac, bindings.PyAttributeAccessor)
     ac2 = bindings.get_accessor(shape.width)
     assert isinstance(ac2, bindings.PyAttributeAccessor)
Exemplo n.º 4
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
Exemplo n.º 5
0
 def test_pynode_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube, 'rx')
     assert isinstance(ac, bindings.PyNodeAccessor)
     ac2 = bindings.get_accessor(shape, 'width')
     assert isinstance(ac2, bindings.PyNodeAccessor)
Exemplo n.º 6
0
 def test_pynode_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube, 'rx')
     assert isinstance(ac, bindings.PyNodeAccessor)
     ac2 = bindings.get_accessor(shape, 'width')
     assert isinstance(ac2, bindings.PyNodeAccessor)
Exemplo n.º 7
0
 def test_pyattr_accessor(self):
     cmds.file(new=True, f=True)
     cube, shape = pm.polyCube()
     ac = bindings.get_accessor(cube.rx)
     assert isinstance(ac, bindings.PyAttributeAccessor)
     ac2 = bindings.get_accessor(shape.width)
     assert isinstance(ac2, bindings.PyAttributeAccessor)
Exemplo n.º 8
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'
Exemplo n.º 9
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
Exemplo n.º 10
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)
Exemplo n.º 11
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)
Exemplo n.º 12
0
    def test_find_simple_property(self):
        class Dummy(object):
            def __init__(self):
                self.Property = 999

        sample = Dummy()
        accessor = bindings.get_accessor(sample, 'Property')
        assert isinstance(accessor, bindings.Accessor)
        assert accessor.pull() == 999
Exemplo n.º 13
0
    def test_find_simple_property(self):
        class Dummy(object):
            def __init__(self):
                self.Property = 999

        sample = Dummy()
        accessor = bindings.get_accessor(sample, 'Property')
        assert isinstance(accessor, bindings.Accessor)
        assert accessor.pull() == 999
Exemplo n.º 14
0
    def test_find_mapped_on_mapping_derived(self):
        class MapTest(object):
            def __init__(self):
                self.secret = 999

            def __getitem__(self, key):
                if key == 'test':
                    return self.secret
                else:
                    return -999

            def __setitem__(self, key, val):
                if key == 'test': self.secret = val

            def __len__(self):
                return 1

        example = MapTest()
        accessor = bindings.get_accessor(example, 'test')
        assert isinstance(accessor, bindings.DictAccessor)
        assert accessor.pull() == 999
Exemplo n.º 15
0
    def test_find_mapped_on_mapping_derived(self):

        class MapTest(object):
            def __init__(self):
                self.secret = 999

            def __getitem__(self, key):
                if key == 'test':
                    return self.secret
                else:
                    return -999

            def __setitem__(self, key, val):
                if key == 'test': self.secret = val

            def __len__(self):
                return 1

        example = MapTest()
        accessor = bindings.get_accessor(example, 'test')
        assert isinstance(accessor, bindings.DictAccessor)
        assert accessor.pull() == 999
Exemplo n.º 16
0
 def test_find_mapped_property(self):
     sample = {'hello': 'world'}
     accessor = bindings.get_accessor(sample, 'hello')
     assert isinstance(accessor, bindings.DictAccessor)
     assert accessor.pull() == 'world'
Exemplo n.º 17
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'
Exemplo n.º 18
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
Exemplo n.º 19
0
    def test_cmds_accessor(self):
        cmds.file(new=True, f=True)

        ac = bindings.get_accessor('persp', 'tx')
        assert isinstance(ac, bindings.CmdsAccessor)
Exemplo n.º 20
0
 def test_pynode_accessor_excepts_for_nonexistent_attrib(self):
     cmds.file(new=True, f=True)
     cube, _ = pm.polyCube()
     self.assertRaises(bindings.BindingError, lambda: bindings.get_accessor(cube, 'xyz'))
Exemplo n.º 21
0
 def test_cmds_accessor_excepts_for_nonexistent_object(self):
     cmds.file(new=True, f=True)
     self.assertRaises(bindings.BindingError,
                       lambda: bindings.get_accessor('dont_exist', 'tx'))
Exemplo n.º 22
0
 def test_cmds_accessor_excepts_for_nonexistent_attrrib(self):
     cmds.file(new=True, f=True)
     self.assertRaises(bindings.BindingError, lambda: bindings.get_accessor('persp', 'dontexist'))
Exemplo n.º 23
0
 def test_cmds_accessor_excepts_for_nonexistent_object(self):
     cmds.file(new=True, f=True)
     self.assertRaises(bindings.BindingError, lambda: bindings.get_accessor('dont_exist', 'tx'))
Exemplo n.º 24
0
    def test_cmds_accessor(self):
        cmds.file(new=True, f=True)

        ac = bindings.get_accessor('persp', 'tx')
        assert isinstance(ac, bindings.CmdsAccessor)
Exemplo n.º 25
0
 def test_find_mapped_property(self):
     sample = {'hello': 'world'}
     accessor = bindings.get_accessor(sample, 'hello')
     assert isinstance(accessor, bindings.DictAccessor)
     assert accessor.pull() == 'world'
Exemplo n.º 26
0
 def test_cmds_accessor_excepts_for_nonexistent_attrrib(self):
     cmds.file(new=True, f=True)
     self.assertRaises(bindings.BindingError,
                       lambda: bindings.get_accessor('persp', 'dontexist'))
Exemplo n.º 27
0
 def test_pynode_accessor_excepts_for_nonexistent_attrib(self):
     cmds.file(new=True, f=True)
     cube, _ = pm.polyCube()
     self.assertRaises(bindings.BindingError,
                       lambda: bindings.get_accessor(cube, 'xyz'))
Exemplo n.º 28
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()
Exemplo n.º 29
0
 def test_basic_binding(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