#NEWLINE# def test_subscribers_non_empty( self ) : #NEWLINE# #INDENT# from zope.interface.declarations import InterfaceClass #NEWLINE# from zope.interface.declarations import implementer #NEWLINE# class IFoo ( InterfaceClass ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# ifoo = IFoo ( 'IFoo' ) #NEWLINE# ibar = IFoo ( 'IBar' ) #NEWLINE# class _Factory ( object ) : #NEWLINE# #INDENT# __component_adapts__ = ( ibar , ) #NEWLINE# def __init__( self , context ) : #NEWLINE# #INDENT# self . _context = context #NEWLINE# #UNINDENT# #UNINDENT# class _Derived ( _Factory ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# comp = self . _makeOne ( ) #NEWLINE# comp . registerSubscriptionAdapter ( _Factory , ( ibar , ) , ifoo ) #NEWLINE# comp . registerSubscriptionAdapter ( _Derived , ( ibar , ) , ifoo ) #NEWLINE# @ implementer ( ibar ) #NEWLINE# class Bar ( object ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# bar = Bar ( ) #NEWLINE# subscribers = comp . subscribers ( ( bar , ) , ifoo ) #NEWLINE# def _klassname( x ) : #NEWLINE# #INDENT# return x . __class__ . __name__ #NEWLINE# #UNINDENT# subscribers = sorted ( subscribers , key = _klassname ) #NEWLINE# self . assertEqual ( len ( subscribers ) , 2 ) #NEWLINE# self . failUnless ( isinstance ( subscribers [ 0 ] , _Derived ) ) #NEWLINE# self . failUnless ( isinstance ( subscribers [ 1 ] , _Factory ) )