예제 #1
0
파일: habitat.py 프로젝트: mikhtonyuk/pyhk2
    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)
예제 #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"})
예제 #3
0
 def testClassAnnotationsList(self):
     self.assertEqual(len(Annotations.getAnnotations(Foo)), 1)
예제 #4
0
 def testClassAnnotationsParams(self):
     self.assertEqual(len(Annotations.getAnnotations(Bar)), 1)
     self.assertEqual(Annotations.getAnnotations(Bar)[0].data, "bar")
예제 #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