MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testExceptions

Method testExceptions

test/IECore/LRUCacheTest.py:315–339  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

313 IECore.testParallelLRUCacheRecursion( 100000, 1000, 100 )
314
315 def testExceptions( self ) :
316
317 calls = []
318 def getter( key ) :
319
320 calls.append( key )
321 raise ValueError( "Get failed for {0}".format( key ) )
322
323 c = IECore.LRUCache( getter, 1000 )
324
325 # Check that the exception thrown by the getter propagates back out to us.
326 self.assertRaisesRegex( RuntimeError, "Get failed for 10", c.get, 10 )
327 self.assertEqual( calls, [ 10 ] )
328 # Check that calling a second time gives us the same error, but without
329 # calling the getter again.
330 self.assertRaisesRegex( RuntimeError, "Get failed for 10", c.get, 10 )
331 self.assertEqual( calls, [ 10 ] )
332 # Check that clear erases exceptions, so that the getter will be called again.
333 c.clear()
334 self.assertRaisesRegex( RuntimeError, "Get failed for 10", c.get, 10 )
335 self.assertEqual( calls, [ 10, 10 ] )
336 # And check that erase does the same.
337 c.erase( 10 )
338 self.assertRaisesRegex( RuntimeError, "Get failed for 10", c.get, 10 )
339 self.assertEqual( calls, [ 10, 10, 10 ] )
340
341 def testSetLimitsCost( self ) :
342

Callers

nothing calls this directly

Calls 2

clearMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected