From f7288657f1a76f2d67d3caeee089dd7fae3c9ee9 Mon Sep 17 00:00:00 2001 From: Daniel Dresser Date: Fri, 3 Nov 2023 17:40:37 -0700 Subject: [PATCH] DuplicateTest : Test that uses Duplicate to expose exception issue --- python/GafferSceneTest/DuplicateTest.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/python/GafferSceneTest/DuplicateTest.py b/python/GafferSceneTest/DuplicateTest.py index eceaa846304..2a28ab9f3ef 100644 --- a/python/GafferSceneTest/DuplicateTest.py +++ b/python/GafferSceneTest/DuplicateTest.py @@ -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()