I have a task
def task():
a = worker()
a.do_some_work()
Worker
itself is a separate class in separate module, who use Driver
class like that,
class Worker(object):
def __init__(self):
self.driver = Driver(args)
...
and once again Driver
is a separate class in separate module
so when I trying something like
with patch('package.module.Driver', new=Mock(return_value=999)):
task()
in task there is still a Driver
class instance, but not a mock. That's wrong. How to fix that?
UPD1:
Driver
and Worker
live in different modules and Worker
import Driver