

def testLoadScriptWithReference(self):
    s = Gaffer.ScriptNode()
    s['n1'] = GafferTest.AddNode()
    s['n2'] = GafferTest.AddNode()
    s['n3'] = GafferTest.AddNode()
    s['n2']['op1'].setInput(s['n1']['sum'])
    s['n3']['op1'].setInput(s['n2']['sum'])
    b = Gaffer.Box.create(s, Gaffer.StandardSet([s['n2']]))
    b.promotePlug(b['n2']['op2'])
    b.exportForReference('/tmp/test.grf')
    s2 = Gaffer.ScriptNode()
    s2['r'] = Gaffer.Reference()
    s2['r'].load('/tmp/test.grf')
    s2['a'] = GafferTest.AddNode()
    s2['r']['op2'].setValue(123)
    s2['r']['op1'].setInput(s2['a']['sum'])
    self.assertTrue(('n2' in s2['r']))
    self.assertTrue(('sum' in s2['r']))
    self.assertTrue(s2['r']['op1'].getInput().isSame(s2['a']['sum']))
    s2['fileName'].setValue('/tmp/test.gfr')
    s2.save()
    s3 = Gaffer.ScriptNode()
    s2['fileName'].setValue('/tmp/test.gfr')
    s3.load()
    self.assertEqual(s3['r'].keys(), s2['r'].keys())
    self.assertEqual(s3['r']['user'].keys(), s2['r']['user'].keys())
    self.assertEqual(s3['r']['op2'].getValue(), 123)
    self.assertTrue(s3['r']['op1'].getInput().isSame(s3['a']['sum']))

dataset/ETHPy150Open ImageEngine/gaffer/python/GafferTest/ReferenceTest.py ReferenceTest.testLoadScriptWithReference/VarMisuse@284/439 `s3`->`s2`