<s> import os <EOL> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> import GafferScene <EOL> import GafferSceneTest <EOL> class SubTreeTest ( GafferSceneTest . SceneTestCase ) : <EOL> def testPassThrough ( self ) : <EOL> a = GafferScene . AlembicSource ( ) <EOL> a [ "<STR_LIT>" ] . setValue ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( a [ "<STR_LIT>" ] ) <EOL> self . assertSceneValid ( s [ "<STR_LIT>" ] , assertBuiltInSetsComplete = False ) <EOL> self . assertScenesEqual ( a [ "<STR_LIT>" ] , s [ "<STR_LIT>" ] ) <EOL> self . assertSceneHashesEqual ( a [ "<STR_LIT>" ] , s [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) . isSame ( s [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) ) ) <EOL> def testSubTree ( self ) : <EOL> a = GafferScene . AlembicSource ( ) <EOL> a [ "<STR_LIT>" ] . setValue ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( a [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> self . assertSceneValid ( s [ "<STR_LIT>" ] ) <EOL> self . assertScenesEqual ( s [ "<STR_LIT>" ] , a [ "<STR_LIT>" ] , scenePlug2PathPrefix = "<STR_LIT>" ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) . isSame ( s [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) ) ) <EOL> def testSets ( self ) : <EOL> l = GafferSceneTest . TestLight ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( g [ "<STR_LIT>" ] ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> def testRootHashesEqual ( self ) : <EOL> a = GafferScene . AlembicSource ( ) <EOL> a [ "<STR_LIT>" ] . setValue ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( a [ "<STR_LIT>" ] ) <EOL> self . assertSceneValid ( s [ "<STR_LIT>" ] , assertBuiltInSetsComplete = False ) <EOL> self . assertPathHashesEqual ( a [ "<STR_LIT>" ] , "<STR_LIT:/>" , s [ "<STR_LIT>" ] , "<STR_LIT:/>" ) <EOL> def testDisabled ( self ) : <EOL> p = GafferScene . Plane ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( p [ "<STR_LIT>" ] ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( False ) <EOL> self . assertSceneValid ( s [ "<STR_LIT>" ] ) <EOL> self . assertScenesEqual ( s [ "<STR_LIT>" ] , g [ "<STR_LIT>" ] ) <EOL> self . assertSceneHashesEqual ( s [ "<STR_LIT>" ] , g [ "<STR_LIT>" ] ) <EOL> def testForwardDeclarationsFromOmittedBranchAreOmitted ( self ) : <EOL> l = GafferSceneTest . TestLight ( ) <EOL> lg1 = GafferScene . Group ( ) <EOL> lg1 [ "<STR_LIT:name>" ] . setValue ( "<STR_LIT>" ) <EOL> lg1 [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> lg2 = GafferScene . Group ( ) <EOL> lg2 [ "<STR_LIT:name>" ] . setValue ( "<STR_LIT>" ) <EOL> lg2 [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> lg3 = GafferScene . Group ( ) <EOL> lg3 [ "<STR_LIT:name>" ] . setValue ( "<STR_LIT>" ) <EOL> lg3 [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> lg4 = GafferScene . Group ( ) <EOL> lg4 [ "<STR_LIT:name>" ] . setValue ( "<STR_LIT>" ) <EOL> lg4 [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( lg1 [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( lg2 [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . setInput ( lg3 [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:3> ] . setInput ( lg4 [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( g [ "<STR_LIT>" ] ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] . setValue ( True ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> def testSetsPassThroughWhenNoRoot ( self ) : <EOL> l = GafferSceneTest . TestLight ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT:/>" ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] . setValue ( True ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT:/>" ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> def testAffects ( self ) : <EOL> s = GafferScene . SubTree ( ) <EOL> for n in s [ "<STR_LIT>" ] . keys ( ) : <EOL> a = s . affects ( s [ "<STR_LIT>" ] [ n ] ) <EOL> self . assertEqual ( len ( a ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( a [ <NUM_LIT:0> ] . isSame ( s [ "<STR_LIT>" ] [ n ] ) ) <EOL> def testIncludeRoot ( self ) : <EOL> a = GafferScene . AlembicSource ( ) <EOL> a [ "<STR_LIT>" ] . setValue ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( a [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( True ) <EOL> self . assertSceneValid ( s [ "<STR_LIT>" ] ) <EOL> self . assertScenesEqual ( s [ "<STR_LIT>" ] , a [ "<STR_LIT>" ] , pathsToIgnore = [ "<STR_LIT:/>" , ] ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] . childNames ( "<STR_LIT:/>" ) , IECore . InternedStringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] . bound ( "<STR_LIT:/>" ) , a [ "<STR_LIT>" ] . bound ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) . isSame ( s [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) ) ) <EOL> def testRootBoundWithTransformedChild ( self ) : <EOL> a = GafferScene . AlembicSource ( ) <EOL> a [ "<STR_LIT>" ] . setValue ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( a [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( True ) <EOL> with Gaffer . Context ( ) as c : <EOL> c . setFrame ( <NUM_LIT:10> ) <EOL> expectedRootBound = a [ "<STR_LIT>" ] . bound ( "<STR_LIT>" ) <EOL> expectedRootBound = expectedRootBound . transform ( a [ "<STR_LIT>" ] . transform ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] . bound ( "<STR_LIT:/>" ) , expectedRootBound ) <EOL> def testIncludeRootPassesThroughWhenNoRootSpecified ( self ) : <EOL> a = GafferScene . AlembicSource ( ) <EOL> a [ "<STR_LIT>" ] . setValue ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( a [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( True ) <EOL> self . assertSceneValid ( s [ "<STR_LIT>" ] , assertBuiltInSetsComplete = False ) <EOL> self . assertScenesEqual ( a [ "<STR_LIT>" ] , s [ "<STR_LIT>" ] ) <EOL> self . assertSceneHashesEqual ( a [ "<STR_LIT>" ] , s [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) . isSame ( s [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) ) ) <EOL> def testSetsWithIncludeRoot ( self ) : <EOL> l = GafferSceneTest . TestLight ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( g [ "<STR_LIT>" ] ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] . setValue ( True ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> def testSetsWithNoLeadingSlash ( self ) : <EOL> l = GafferSceneTest . TestLight ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( g [ "<STR_LIT>" ] ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> lightSet = s [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) <EOL> self . assertEqual ( lightSet . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertSetsValid ( s [ "<STR_LIT>" ] ) <EOL> def testSetNamesAndGlobalsPassThrough ( self ) : <EOL> l = GafferSceneTest . TestLight ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( l [ "<STR_LIT>" ] ) <EOL> s = GafferScene . SubTree ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:root>" ] . setValue ( "<STR_LIT>" ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) , g [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) ) <EOL> self . assertTrue ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( _copy = False ) . isSame ( g [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( _copy = False ) ) ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) , g [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hash ( ) ) <EOL> self . assertTrue ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( _copy = False ) . isSame ( g [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( _copy = False ) ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
