С учетом структур классов:
class BaseDataset:
def _create_context_in_base(self):
return "some_context"
class Dataset(BaseDataset):
def create_context(self):
return self._create_context_in_base()
Я пытаюсь проверить с макетом, как:
def override_method():
config = dict({"A":1})
ctx = OBJECT_REQUIRED.create_context() """ How to get this object. Method doesn't take any argument in source """
ctx.update_config(config)
return ctx
class DatasetTests(unittest.TestCase):
def test_dataloader(self):
dataset = create_dataset()
...
with patch.object(dataset, "create_context", new=override_method):
....