Skip to content

Commit

Permalink
ComputeNodeTest : Test exception handling for all cache policies
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Oct 9, 2023
1 parent 5f87394 commit 5773b55
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions python/GafferTest/ComputeNodeTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ class ThrowingNode( Gaffer.ComputeNode ) :
def __init__( self, name="ThrowingNode" ) :

self.hashFail = False
self.cachePolicy = Gaffer.ValuePlug.CachePolicy.Standard

Gaffer.ComputeNode.__init__( self, name )

Expand Down Expand Up @@ -639,11 +640,11 @@ def compute( self, plug, context ) :

def hashCachePolicy( self, plug ) :

return Gaffer.ValuePlug.CachePolicy.Standard
return self.cachePolicy

def computeCachePolicy( self, plug ) :

return Gaffer.ValuePlug.CachePolicy.Standard
return self.cachePolicy

IECore.registerRunTimeTyped( ThrowingNode )

Expand Down Expand Up @@ -684,18 +685,25 @@ def testProcessException( self ) :

def testProcessExceptionNotShared( self ) :

thrower1 = self.ThrowingNode( "thrower1" )
thrower2 = self.ThrowingNode( "thrower2" )
for policy in Gaffer.ValuePlug.CachePolicy.names.values() :
with self.subTest( policy = policy ) :

with self.assertRaisesRegex( Gaffer.ProcessException, r'thrower1.out : [\s\S]*Eeek!' ) as raised :
thrower1["out"].getValue()
Gaffer.ValuePlug.clearCache()

self.assertEqual( raised.exception.plug(), thrower1["out"] )
thrower1 = self.ThrowingNode( "thrower1" )
thrower1.cachePolicy = policy
thrower2 = self.ThrowingNode( "thrower2" )
thrower2.cachePolicy = policy

with self.assertRaisesRegex( Gaffer.ProcessException, r'thrower2.out : [\s\S]*Eeek!' ) as raised :
thrower2["out"].getValue()
with self.assertRaisesRegex( Gaffer.ProcessException, r'thrower1.out : [\s\S]*Eeek!' ) as raised :
thrower1["out"].getValue()

self.assertEqual( raised.exception.plug(), thrower1["out"] )

with self.assertRaisesRegex( Gaffer.ProcessException, r'thrower2.out : [\s\S]*Eeek!' ) as raised :
thrower2["out"].getValue()

self.assertEqual( raised.exception.plug(), thrower2["out"] )
self.assertEqual( raised.exception.plug(), thrower2["out"] )

def testProcessExceptionRespectsNameChanges( self ) :

Expand Down

0 comments on commit 5773b55

Please sign in to comment.