Пример #1
0
 def test_it(self):
     from repoze.depinj import inject_factory
     from repoze.depinj import construct
     def factory1():
         return 'factory1'
     def factory2():
         return 'factory2'
     thunk1 = inject_factory(factory1, Dummy)
     thunk2 = inject_factory(factory2, Dummy)
     construct(Dummy)
     construct(Dummy)
     self.assertEqual(thunk2(), 'factory2')
     self.assertEqual(thunk1(), 'factory1')
     self.assertEqual(construct(Dummy).__class__, Dummy)
Пример #2
0
 def test_it_injected(self):
     from repoze.depinj import construct
     from repoze.depinj import injector
     promise = injector.inject_factory(DummyFactory, 'whatever')
     self.assertEqual(construct('whatever', 'a', b=1).__class__,DummyFactory)
     fixture = promise()
     self.assertEqual(fixture.arg, ('a',))
     self.assertEqual(fixture.kw, {'b':1})
Пример #3
0
 def test_it_not_injected(self):
     from repoze.depinj import construct
     self.assertEqual(construct(DummyFactory).__class__, DummyFactory)