#NEWLINE# @ pytest . mark . parametrize ( 'success' , [ True , False ] ) #NEWLINE# def test_after_commit_hook( self , monkeypatch , success ) : #NEWLINE# #INDENT# args = [ pretend . stub ( ) , pretend . stub ( ) ] #NEWLINE# kwargs = { #NEWLINE# #INDENT# 'foo' : pretend . stub ( ) , #NEWLINE# 'bar' : pretend . stub ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# super_class = pretend . stub ( apply_async = pretend . call_recorder ( ( lambda * a , **kw : None ) ) ) #NEWLINE# real_super = __builtins__ [ 'super' ] #NEWLINE# inner_super = pretend . call_recorder ( ( lambda * a , **kw : super_class ) ) #NEWLINE# def fake_super( * args , **kwargs ) : #NEWLINE# #INDENT# if ( ( not args ) and ( not kwargs ) ) : #NEWLINE# #INDENT# return inner_super ( * args , ** kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return real_super ( * args , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# monkeypatch . setitem ( __builtins__ , 'super' , fake_super ) #NEWLINE# task = celery . WarehouseTask ( ) #NEWLINE# task . app = Celery ( ) #NEWLINE# task . _after_commit_hook ( success , * args , ** kwargs ) #NEWLINE# if success : #NEWLINE# #INDENT# assert ( self . calls == [ pretend . call ( ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert ( inner_super . calls == [ ] )