def test_function_service_factory(self):

        class IFoo(Interface):
            price = Int

        @provides(IFoo)
        class Foo(HasTraits):
            price = Int

        def foo_factory(**properties):
            """ A factory for foos. """

            return Foo(**properties)

        # Register a service factory.
        self.service_registry.register_service(
            IFoo, foo_factory, {'price' : 100}
        )

        # Create a query that matches the registered object.
        service = self.service_registry.get_service(IFoo, 'price <= 100')
        self.assertNotEqual(None, service)
        self.assertEqual(Foo, type(service))

        # Make sure that the object created by the factory is cached (i.e. we
        # get the same object back from now on!).
        service2 = self.service_registry.get_service(IFoo, 'price <= 100')
        self.assert_(service is service2)

        return
function service factory
dataset/ETHPy150Open enthought/envisage/envisage/tests/service_registry_test_case.py/ServiceRegistryTestCase.test_function_service_factory