#NEWLINE# def testIndexExpression( self ) : #NEWLINE# #INDENT# script = Gaffer . ScriptNode ( ) #NEWLINE# script [ 's' ] = self . intSwitch ( ) #NEWLINE# script [ 'a1' ] = GafferTest . AddNode ( ) #NEWLINE# script [ 'a2' ] = GafferTest . AddNode ( ) #NEWLINE# script [ 'a1' ] [ 'op1' ] . setValue ( 1 ) #NEWLINE# script [ 'a2' ] [ 'op2' ] . setValue ( 2 ) #NEWLINE# script [ 's' ] [ 'in' ] [ 0 ] . setInput ( self [ 'a1' ] [ 'sum' ] ) #NEWLINE# script [ 's' ] [ 'in' ] [ 1 ] . setInput ( script [ 'a2' ] [ 'sum' ] ) #NEWLINE# self . assertTrue ( ( script [ 's' ] [ 'out' ] . getInput ( ) is not None ) ) #NEWLINE# script [ 'expression' ] = Gaffer . Expression ( ) #NEWLINE# script [ 'expression' ] . setExpression ( 'parent["s"]["index"] = int( context.getFrame() )' ) #NEWLINE# self . assertTrue ( ( script [ 's' ] [ 'out' ] . getInput ( ) is None ) ) #NEWLINE# with script . context ( ) : #NEWLINE# #INDENT# script . context ( ) . setFrame ( 0 ) #NEWLINE# self . assertEqual ( script [ 's' ] [ 'out' ] . getValue ( ) , 1 ) #NEWLINE# script . context ( ) . setFrame ( 1 ) #NEWLINE# self . assertEqual ( script [ 's' ] [ 'out' ] . getValue ( ) , 2 ) #NEWLINE# #UNINDENT# del script [ 'expression' ] #NEWLINE# self . assertTrue ( ( script [ 's' ] [ 'out' ] . getInput ( ) is not None ) )