#NEWLINE# def test_registerUtility_w_component( self ) : #NEWLINE# #INDENT# from zope.interface.declarations import InterfaceClass #NEWLINE# from zope.interface.interfaces import Registered #NEWLINE# from zope.interface.registry import UtilityRegistration #NEWLINE# from zope.interface._compat import _u #NEWLINE# class IFoo ( InterfaceClass ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# ifoo = IFoo ( 'IFoo' ) #NEWLINE# _info = _u ( 'info' ) #NEWLINE# _name = _u ( 'name' ) #NEWLINE# _to_reg = object ( ) #NEWLINE# comp = self . _makeOne ( ) #NEWLINE# ( _monkey , _events ) = self . _wrapEvents ( ) #NEWLINE# with _monkey : #NEWLINE# #INDENT# comp . registerUtility ( _to_reg , ifoo , _name , _info ) #NEWLINE# #UNINDENT# self . failUnless ( ( comp . utilities . _adapters [ 0 ] [ ifoo ] [ _name ] is _to_reg ) ) #NEWLINE# self . assertEqual ( comp . _utility_registrations [ ( ifoo , comp ) ] , ( _to_reg , _info , None ) ) #NEWLINE# self . assertEqual ( comp . utilities . _subscribers [ 0 ] [ ifoo ] [ '' ] , ( _to_reg , ) ) #NEWLINE# self . assertEqual ( len ( _events ) , 1 ) #NEWLINE# ( args , kw ) = _events [ 0 ] #NEWLINE# ( event , ) = args #NEWLINE# self . assertEqual ( kw , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . failUnless ( isinstance ( event , Registered ) ) #NEWLINE# self . failUnless ( isinstance ( event . object , UtilityRegistration ) ) #NEWLINE# self . failUnless ( ( event . object . registry is comp ) ) #NEWLINE# self . failUnless ( ( event . object . provided is ifoo ) ) #NEWLINE# self . failUnless ( ( event . object . name is _name ) ) #NEWLINE# self . failUnless ( ( event . object . component is _to_reg ) ) #NEWLINE# self . failUnless ( ( event . object . info is _info ) ) #NEWLINE# self . failUnless ( ( event . object . factory is None ) )