def test_remove_provider(self): ij = Injector() ij.add_value('val', 5) ij.remove('val') def test(val): pass with self.assertRaises(InjectError): ij.call_inject(test)
def test_inject_value(self): ij = Injector() value = [] ij.add_value('val', value) def test(val, other=inject('val')): self.assertTrue(val is other) self.assertTrue(val is value) val.append(5) ij.call_inject(test) self.assertEqual([5], value)
def test_wrap_decorator(self): ij = Injector() @ij.wrap def test(a): return a with self.assertRaises(InjectError): test() ij.add_value('a', 5) self.assertEquals(5, test()) self.assertEquals(6, test(a=6))