def test_invalid(error, kwargs): container = DependencyContainer() def f(x): return x with pytest.raises(error): inject(f, container=container, **kwargs)()
def test_no_injections(): container = DependencyContainer() def f(x): return x injected_f = inject(f, container=container) # When nothing can be injected, the same function should be returned assert injected_f is f
def test_already_injected(): container = DependencyContainer() @inject(container=container, use_names=True) def f(x): return x injected_f = inject(f, container=container) # When the function has already its arguments injected, the same function should # be returned assert injected_f is f