

def testOverrideAttributes(self):
    sphere = IECore.SpherePrimitive()
    input = GafferSceneTest.CompoundObjectSource()
    input['in'].setValue(IECore.CompoundObject({
        'bound': IECore.Box3fData(sphere.bound()),
        'children': {
            'ball1': {
                'object': sphere,
                'bound': IECore.Box3fData(sphere.bound()),
            },
        },
    }))
    a = GafferScene.CustomAttributes()
    a['in'].setInput(input['out'])
    a['attributes'].addMember('ri:shadingRate', IECore.FloatData(0.25))
    a['attributes'].addMember('user:something', IECore.IntData(1))
    self.assertEqual(a['out'].attributes('/ball1'), IECore.CompoundObject({
        'ri:shadingRate': IECore.FloatData(0.25),
        'user:something': IECore.IntData(1),
    }))
    a2 = GafferScene.CustomAttributes()
    a2['in'].setInput(a['out'])
    self.assertEqual(a2['out'].attributes('/ball1'), IECore.CompoundObject({
        'ri:shadingRate': IECore.FloatData(0.25),
        'user:something': IECore.IntData(1),
    }))
    a2['attributes'].addMember('ri:shadingRate', IECore.FloatData(0.5))
    a2['attributes'].addMember('user:somethingElse', IECore.IntData(10))
    self.assertEqual(a2['out'].attributes('/ball1'), IECore.CompoundObject({
        'ri:shadingRate': IECore.FloatData(0.5),
        'user:something': IECore.IntData(1),
        'user:somethingElse': IECore.IntData(10),
    }))

dataset/ETHPy150Open ImageEngine/gaffer/python/GafferSceneTest/CustomAttributesTest.py CustomAttributesTest.testOverrideAttributes/original