

def testUndoOfPersistentInstanceValues(self):
    s = Gaffer.ScriptNode()
    s['n'] = GafferTest.AddNode()

    def assertNonExistent():
        self.assertEqual(Gaffer.Metadata.nodeValue(s['n'], 'a'), None)
        self.assertEqual(Gaffer.Metadata.plugValue(s['n']['op1'], 'b'), None)

    def assertPersistent():
        self.assertEqual(Gaffer.Metadata.registeredNodeValues(s['n'], instanceOnly=True), ['a'])
        self.assertEqual(Gaffer.Metadata.registeredPlugValues(s['n']['op1'], instanceOnly=True), ['b'])
        self.assertEqual(Gaffer.Metadata.registeredNodeValues(s['n'], instanceOnly=True, persistentOnly=True), ['a'])
        self.assertEqual(Gaffer.Metadata.registeredPlugValues(s['n']['op1'], instanceOnly=True, persistentOnly=True), ['b'])
        self.assertEqual(Gaffer.Metadata.nodeValue(s['n'], 'a'), 1)
        self.assertEqual(Gaffer.Metadata.plugValue(s['n']['op1'], 'b'), 2)

    def assertNonPersistent():
        self.assertEqual(Gaffer.Metadata.registeredNodeValues(s['n'], instanceOnly=True), ['a'])
        self.assertEqual(Gaffer.Metadata.registeredPlugValues(s['n']['op1'], instanceOnly=True), ['b'])
        self.assertEqual(Gaffer.Metadata.registeredNodeValues(s['n'], instanceOnly=True, persistentOnly=True), [])
        self.assertEqual(Gaffer.Metadata.registeredPlugValues(s['n']['op1'], instanceOnly=True, persistentOnly=True), [])
        self.assertEqual(Gaffer.Metadata.nodeValue(s['n'], 'a'), 1)
        self.assertEqual(Gaffer.Metadata.plugValue(s['n']['op1'], 'b'), 2)
    assertNonExistent()
    with Gaffer.UndoContext(s):
        Gaffer.Metadata.registerNodeValue(s['n'], 'a', 1, persistent=True)
        Gaffer.Metadata.registerPlugValue(s['n']['op1'], 'b', 2, persistent=True)
    assertPersistent()
    with Gaffer.UndoContext(self):
        Gaffer.Metadata.registerNodeValue(s['n'], 'a', 1, persistent=False)
        Gaffer.Metadata.registerPlugValue(s['n']['op1'], 'b', 2, persistent=False)
    assertNonPersistent()
    s.undo()
    assertPersistent()
    s.undo()
    assertNonExistent()
    s.redo()
    assertPersistent()
    s.redo()
    assertNonPersistent()

dataset/ETHPy150Open ImageEngine/gaffer/python/GafferTest/MetadataTest.py MetadataTest.testUndoOfPersistentInstanceValues/VarMisuse@484/699 `s`->`self`