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)
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"})
def testClassAnnotationsList(self): self.assertEqual(len(Annotations.getAnnotations(Foo)), 1)
def testClassAnnotationsParams(self): self.assertEqual(len(Annotations.getAnnotations(Bar)), 1) self.assertEqual(Annotations.getAnnotations(Bar)[0].data, "bar")
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