<s> import os <EOL> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferImage <EOL> import GafferScene <EOL> import GafferSceneTest <EOL> @ unittest . skipIf ( "<STR_LIT>" in os . environ , "<STR_LIT>" ) <EOL> class OpenGLRenderTest ( GafferSceneTest . SceneTestCase ) : <EOL> def test ( self ) : <EOL> self . assertFalse ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Plane ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . V3f ( <NUM_LIT:0> , <NUM_LIT:0> , - <NUM_LIT:5> ) ) <EOL> s [ "<STR_LIT:image>" ] = GafferImage . ImageReader ( ) <EOL> s [ "<STR_LIT:image>" ] [ "<STR_LIT>" ] . setValue ( os . path . expandvars ( "<STR_LIT>" ) ) <EOL> s [ "<STR_LIT>" ] = GafferScene . OpenGLShader ( ) <EOL> s [ "<STR_LIT>" ] . loadShader ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT:image>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:1> ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . Color4f ( <NUM_LIT:1> ) ) <EOL> s [ "<STR_LIT>" ] = GafferScene . ShaderAssignment ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Outputs ( ) <EOL> s [ "<STR_LIT>" ] . addOutput ( <EOL> "<STR_LIT>" , <EOL> IECore . Display ( <EOL> self . temporaryDirectory ( ) + "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> { } <EOL> ) <EOL> ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] = GafferScene . OpenGLRender ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] . setValue ( self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> s . save ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . execute ( ) <EOL> self . assertTrue ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> i = IECore . EXRImageReader ( self . temporaryDirectory ( ) + "<STR_LIT>" ) . read ( ) <EOL> e = IECore . ImagePrimitiveEvaluator ( i ) <EOL> r = e . createResult ( ) <EOL> e . pointAtUV ( IECore . V2f ( <NUM_LIT:0.5> ) , r ) <EOL> self . assertAlmostEqual ( r . floatPrimVar ( e . R ( ) ) , <NUM_LIT> , <NUM_LIT:5> ) <EOL> self . assertAlmostEqual ( r . floatPrimVar ( e . G ( ) ) , <NUM_LIT> , <NUM_LIT:5> ) <EOL> self . assertEqual ( r . floatPrimVar ( e . B ( ) ) , <NUM_LIT:0> ) <EOL> def testOutputDirectoryCreation ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] . addMember ( "<STR_LIT>" , self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Plane ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Outputs ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] . addOutput ( <EOL> "<STR_LIT>" , <EOL> IECore . Display ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> { } <EOL> ) <EOL> ) <EOL> s [ "<STR_LIT>" ] = GafferScene . OpenGLRender ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> self . assertFalse ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> self . assertFalse ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> s [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> with s . context ( ) : <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . execute ( ) <EOL> self . assertTrue ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> self . assertTrue ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> def testHash ( self ) : <EOL> c = Gaffer . Context ( ) <EOL> c . setFrame ( <NUM_LIT:1> ) <EOL> c2 = Gaffer . Context ( ) <EOL> c2 . setFrame ( <NUM_LIT:2> ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Plane ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Outputs ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] . addOutput ( "<STR_LIT>" , IECore . Display ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , { } ) ) <EOL> s [ "<STR_LIT>" ] = GafferScene . OpenGLRender ( ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] . hash ( c ) , IECore . MurmurHash ( ) ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> self . assertNotEqual ( s [ "<STR_LIT>" ] . hash ( c ) , IECore . MurmurHash ( ) ) <EOL> self . assertNotEqual ( s [ "<STR_LIT>" ] . hash ( c ) , s [ "<STR_LIT>" ] . hash ( c2 ) ) <EOL> current = s [ "<STR_LIT>" ] . hash ( c ) <EOL> c [ "<STR_LIT>" ] = self . temporaryDirectory ( ) + "<STR_LIT>" <EOL> self . assertNotEqual ( s [ "<STR_LIT>" ] . hash ( c ) , current ) <EOL> current = s [ "<STR_LIT>" ] . hash ( c ) <EOL> c [ "<STR_LIT>" ] = self . temporaryDirectory ( ) + "<STR_LIT>" <EOL> self . assertNotEqual ( s [ "<STR_LIT>" ] . hash ( c ) , current ) <EOL> current = s [ "<STR_LIT>" ] . hash ( c ) <EOL> c [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> self . assertEqual ( s [ "<STR_LIT>" ] . hash ( c ) , current ) <EOL> current = s [ "<STR_LIT>" ] . hash ( c ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> self . assertNotEqual ( s [ "<STR_LIT>" ] . hash ( c ) , current ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
