Skip to content

Commit

Permalink
DuplicateTest : Test that uses Duplicate to expose exception issue
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed Nov 4, 2023
1 parent c746fe9 commit f728865
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions python/GafferSceneTest/DuplicateTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,30 @@ def testExistingTransform( self ) :
imath.M44f().translate( imath.V3f( 5, 0, 0 ) )
)

def testUpstreamError( self ):

sphereFilter = GafferScene.PathFilter()
sphereFilter["paths"].setValue( IECore.StringVectorData( [ '/sphere' ] ) )

sphere = GafferScene.Sphere()

purposeAttr = GafferScene.CustomAttributes()
purposeAttr["in"].setInput( sphere["out"] )
purposeAttr["filter"].setInput( sphereFilter["out"] )
purposeAttr["attributes"].addChild( Gaffer.NameValuePlug( "testAttribute", 0 ) )
purposeAttr["expression"] = Gaffer.Expression()
purposeAttr["expression"].setExpression( 'parent["attributes"]["NameValuePlug"]["value"] = 1 / 0', "python" )


duplicate = GafferScene.Duplicate()
duplicate["in"].setInput( purposeAttr["out"] )
duplicate["filter"].setInput( sphereFilter["out"] )
duplicate["copies"].setValue( 100 )

for i in range( 20 ):
with self.subTest( i = i ):
with self.assertRaisesRegex( RuntimeError, "division by zero" ):
GafferSceneTest.traverseScene( duplicate["out"] )

if __name__ == "__main__":
unittest.main()

0 comments on commit f728865

Please sign in to comment.