#NEWLINE# def test_registerSubscriptionAdapter_w_explicit_provided_and_required( self ) : #NEWLINE# #INDENT# from zope.interface.declarations import InterfaceClass #NEWLINE# from zope.interface.interfaces import Registered #NEWLINE# from zope.interface.registry import SubscriptionRegistration #NEWLINE# from zope.interface._compat import _u #NEWLINE# class IFoo ( InterfaceClass ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# ifoo = IFoo ( 'IFoo' ) #NEWLINE# ibar = IFoo ( 'IBar' ) #NEWLINE# _blank = _u ( '' ) #NEWLINE# _info = _u ( 'info' ) #NEWLINE# _to_reg = object ( ) #NEWLINE# def _factory( context ) : #NEWLINE# #INDENT# return _to_reg #NEWLINE# #UNINDENT# comp = self . _makeOne ( ) #NEWLINE# ( _monkey , _events ) = self . _wrapEvents ( ) #NEWLINE# with _monkey : #NEWLINE# #INDENT# comp . registerSubscriptionAdapter ( _factory , ( ibar , ) , ifoo , info = _info ) #NEWLINE# #UNINDENT# reg = comp . adapters . _subscribers [ 1 ] [ ibar ] [ ifoo ] [ _blank ] #NEWLINE# self . assertEqual ( len ( reg ) , 1 ) #NEWLINE# self . failUnless ( ( reg [ 0 ] is _factory ) ) #NEWLINE# self . assertEqual ( comp . _subscription_registrations , [ ( ( ibar , ) , ifoo , _blank , _factory , _info ) ] ) #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 , SubscriptionRegistration ) ) #NEWLINE# self . failUnless ( ( event . object . registry is comp ) ) #NEWLINE# self . failUnless ( ( event . object . provided is ifoo ) ) #NEWLINE# self . assertEqual ( event . object . required , ( ibar , ) ) #NEWLINE# self . assertEqual ( event . object . name , _blank ) #NEWLINE# self . failUnless ( ( event . object . info is _info ) ) #NEWLINE# self . failUnless ( ( event . object . factory is _factory ) )