Exemplo n.º 1
0
    def _regInIoC(self):
        self._ioc.bind(Habitat, self)

        for s, cts in self._servicesToContracts.iteritems():
            [annot] = filter(lambda x: isinstance(x, Service), Annotations.getAnnotations(s))
            scope = annot.scope or NoScope
            scope = scope()

            for c in cts:
                self._ioc.bind(c, s, scope)
Exemplo n.º 2
0
 def testGettingClassesByAnnotations(self):
     module = sys.modules[__name__]
     ats = Annotations.getAnnotatedClasses(module, Test)
     self.assertEqual(len(ats), 2)
     data = set((a[0].data for c, a in ats))
     self.assertSetEqual(data, {None, "bar"})
Exemplo n.º 3
0
 def testClassAnnotationsList(self):
     self.assertEqual(len(Annotations.getAnnotations(Foo)), 1)
Exemplo n.º 4
0
 def testClassAnnotationsParams(self):
     self.assertEqual(len(Annotations.getAnnotations(Bar)), 1)
     self.assertEqual(Annotations.getAnnotations(Bar)[0].data, "bar")
Exemplo n.º 5
0
 def scan(self, module):
     contracts = [c for c, a in Annotations.getAnnotatedClasses(module, Contract)]
     services = [c for c, a in Annotations.getAnnotatedClasses(module, Service)]
     return contracts, services