def test_inject_by_package_name(self): m.do_stuff = lambda: None to_inject = new_app() inject('tests.fixtures', *to_inject) request('foo') validation('bar') update_query()
def test_inject_by_module(self): m.do_stuff = lambda: None to_inject = new_app() inject(m, *to_inject) request('foo') validation('bar') update_query()
def test_inject_error(self): with self.assertRaises(TypeError): to_inject = new_app() inject(m, *to_inject)
from collections import namedtuple from broccoli import inject DependencyA = namedtuple('A', '') DependencyB = namedtuple('B', '') def foo(a, b: DependencyA): return a def bar(a, b: DependencyB): return a inject(__name__, DependencyA(), DependencyB()) assert foo(1) == 1 assert bar(10) == 10