#NEWLINE# def test_lazy_bound_method_service_factory( self ) : #NEWLINE# #INDENT# ' lazy bound method service factory ' #NEWLINE# i_foo = ( PKG + '.i_foo.IFoo' ) #NEWLINE# foo = ( PKG + '.foo' ) #NEWLINE# class ServiceProvider ( HasTraits ) : #NEWLINE# #INDENT# ' A class that provides a service.\n\n            This is used to make sure a bound method can be used as a service\n            factory.\n\n            ' #NEWLINE# def foo_factory( self , **properties ) : #NEWLINE# #INDENT# ' A factory for foos. ' #NEWLINE# from envisage.tests.foo import Foo #NEWLINE# self . foo = Foo ( ) #NEWLINE# return self . foo #NEWLINE# #UNINDENT# #UNINDENT# sp = ServiceProvider ( ) #NEWLINE# self . service_registry . register_service ( i_foo , sp . foo_factory ) #NEWLINE# if ( foo in sys . modules ) : #NEWLINE# #INDENT# del sys . modules [ foo ] #NEWLINE# #UNINDENT# self . assert_ ( ( foo not in sys . modules ) ) #NEWLINE# services = self . service_registry . get_services ( 'bogus.IBogus' ) #NEWLINE# self . assert_ ( ( foo not in sys . modules ) ) #NEWLINE# services = self . service_registry . get_services ( sp ) #NEWLINE# self . assertEqual ( [ sp . foo ] , services ) #NEWLINE# self . assert_ ( ( foo in sys . modules ) ) #NEWLINE# del sys . modules [ foo ] #NEWLINE# return