#NEWLINE# def testParseFailureLeavesStateUnchanged( self ) : #NEWLINE# #INDENT# s = Gaffer . ScriptNode ( ) #NEWLINE# s [ 'n' ] = Gaffer . Node ( ) #NEWLINE# s [ 'n' ] [ 'user' ] [ 'i' ] = Gaffer . IntPlug ( flags = ( Gaffer . Plug . Flags . Default | Gaffer . Plug . Flags . Dynamic ) ) #NEWLINE# s [ 'e' ] = Gaffer . Expression ( ) #NEWLINE# s [ 'e' ] . setExpression ( "parent['n']['user']['i'] = context.getFrame()" ) #NEWLINE# cs = GafferTest . CapturingSlot ( s [ 'e' ] . expressionChangedSignal ( ) ) #NEWLINE# with Gaffer . Context ( ) as c : #NEWLINE# #INDENT# c . setFrame ( 10 ) #NEWLINE# self . assertEqual ( s [ 'n' ] [ 'user' ] [ 'i' ] . getValue ( ) , 10 ) #NEWLINE# c . setFrame ( 20 ) #NEWLINE# self . assertEqual ( s [ 'n' ] [ 'user' ] [ 'i' ] . getValue ( ) , 20 ) #NEWLINE# #UNINDENT# with Gaffer . UndoContext ( s ) : #NEWLINE# #INDENT# self . assertRaisesRegexp ( Exception , 'SyntaxError' , cs [ 'e' ] . setExpression , "i'm not valid python" ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( cs ) , 0 ) #NEWLINE# self . assertFalse ( s . undoAvailable ( ) ) #NEWLINE# with Gaffer . Context ( ) as c : #NEWLINE# #INDENT# c . setFrame ( 11 ) #NEWLINE# self . assertEqual ( s [ 'n' ] [ 'user' ] [ 'i' ] . getValue ( ) , 11 ) #NEWLINE# c . setFrame ( 21 ) #NEWLINE# self . assertEqual ( s [ 'n' ] [ 'user' ] [ 'i' ] . getValue ( ) , 21 )