コード例 #1
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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
コード例 #2
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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()
コード例 #3
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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)
コード例 #4
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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
コード例 #5
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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)
コード例 #6
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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)
コード例 #7
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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)
コード例 #8
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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'
コード例 #9
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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
コード例 #10
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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)
コード例 #11
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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)
コード例 #12
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
    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
コード例 #13
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
    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
コード例 #14
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
    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
コード例 #15
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
    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
コード例 #16
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 def test_find_mapped_property(self):
     sample = {'hello': 'world'}
     accessor = bindings.get_accessor(sample, 'hello')
     assert isinstance(accessor, bindings.DictAccessor)
     assert accessor.pull() == 'world'
コード例 #17
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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'
コード例 #18
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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
コード例 #19
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
    def test_cmds_accessor(self):
        cmds.file(new=True, f=True)

        ac = bindings.get_accessor('persp', 'tx')
        assert isinstance(ac, bindings.CmdsAccessor)
コード例 #20
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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'))
コード例 #21
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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'))
コード例 #22
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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'))
コード例 #23
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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'))
コード例 #24
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
    def test_cmds_accessor(self):
        cmds.file(new=True, f=True)

        ac = bindings.get_accessor('persp', 'tx')
        assert isinstance(ac, bindings.CmdsAccessor)
コード例 #25
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 def test_find_mapped_property(self):
     sample = {'hello': 'world'}
     accessor = bindings.get_accessor(sample, 'hello')
     assert isinstance(accessor, bindings.DictAccessor)
     assert accessor.pull() == 'world'
コード例 #26
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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'))
コード例 #27
0
ファイル: test_Bindings.py プロジェクト: techartorg/mGui
 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'))
コード例 #28
0
ファイル: test_Bindings.py プロジェクト: bob-white/mGui
 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()
コード例 #29
0
ファイル: test_Bindings.py プロジェクト: AdricEpic/mGui
 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