|
|
|
|
|
by bb88
999 days ago
|
|
That DI library is not pythonic at all. There's nothing wrong with this at all, say: class MyClass:
def __init__(self, my_dep1=None):
if my_dep1 is None:
self.my_dep1 = get_my_dep1() # Or potentially raise
else:
self.my_dep1 = my_dep1
[...]
Then to test: def test_my_class():
mocked_dep1 = MagicMock()
my_class = MyClass(my_dep1=mocked_dep1)
[...]
|
|