<s> import os <EOL> import unittest <EOL> import subprocess32 as subprocess <EOL> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> import GafferScene <EOL> import GafferAppleseed <EOL> import GafferAppleseedTest <EOL> class AppleseedRenderTest ( GafferTest . TestCase ) : <EOL> def setUp ( self ) : <EOL> GafferTest . TestCase . setUp ( self ) <EOL> self . __scriptFileName = self . temporaryDirectory ( ) + "<STR_LIT>" <EOL> def testExecute ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Plane ( ) <EOL> s [ "<STR_LIT>" ] = GafferAppleseed . AppleseedRender ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] = Gaffer . Expression ( ) <EOL> s [ "<STR_LIT>" ] . setExpression ( "<STR_LIT>" + self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( self . __scriptFileName ) <EOL> s . save ( ) <EOL> p = subprocess . Popen ( <EOL> "<STR_LIT>" + self . __scriptFileName + "<STR_LIT>" , <EOL> shell = True , <EOL> stderr = subprocess . PIPE , <EOL> ) <EOL> p . wait ( ) <EOL> self . failIf ( p . returncode ) <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:4> ) : <EOL> self . failUnless ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" % i ) ) <EOL> def testWaitForImage ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Plane ( ) <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>" ] = GafferAppleseed . AppleseedRender ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( self . __scriptFileName ) <EOL> s . save ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . execute ( ) <EOL> self . failUnless ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> def testExecuteWithStringSubstitutions ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Plane ( ) <EOL> s [ "<STR_LIT>" ] = GafferAppleseed . AppleseedRender ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( self . __scriptFileName ) <EOL> s . save ( ) <EOL> p = subprocess . Popen ( <EOL> "<STR_LIT>" + self . __scriptFileName + "<STR_LIT>" , <EOL> shell = True , <EOL> stderr = subprocess . PIPE , <EOL> ) <EOL> p . wait ( ) <EOL> self . failIf ( p . returncode ) <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:4> ) : <EOL> self . failUnless ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" % i ) ) <EOL> def testImageOutput ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferScene . Plane ( ) <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>" ] = GafferAppleseed . AppleseedRender ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( self . __scriptFileName ) <EOL> s . save ( ) <EOL> c = Gaffer . Context ( ) <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:4> ) : <EOL> c . setFrame ( i ) <EOL> with c : <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . execute ( ) <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT:4> ) : <EOL> self . failUnless ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" % i ) ) <EOL> def testTypeNamePrefixes ( self ) : <EOL> self . assertTypeNamesArePrefixed ( GafferAppleseed ) <EOL> self . assertTypeNamesArePrefixed ( GafferAppleseedTest ) <EOL> def testDefaultNames ( self ) : <EOL> self . assertDefaultNamesAreCorrect ( GafferAppleseed ) <EOL> self . assertDefaultNamesAreCorrect ( GafferAppleseedTest ) <EOL> def testNodesConstructWithDefaultValues ( self ) : <EOL> self . assertNodesConstructWithDefaultValues ( GafferAppleseed ) <EOL> self . assertNodesConstructWithDefaultValues ( GafferAppleseedTest ) <EOL> def testDirectoryCreation ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] . addMember ( "<STR_LIT>" , self . temporaryDirectory ( ) + "<STR_LIT>" ) <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>" ] = GafferAppleseed . AppleseedRender ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> self . assertFalse ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> self . assertFalse ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> self . assertFalse ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> self . assertFalse ( os . path . exists ( self . __scriptFileName ) ) <EOL> s [ "<STR_LIT>" ] . setValue ( self . __scriptFileName ) <EOL> s . save ( ) <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> self . assertTrue ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> self . assertTrue ( os . path . exists ( self . __scriptFileName ) ) <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> self . assertTrue ( os . path . exists ( self . temporaryDirectory ( ) + "<STR_LIT>" ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
