adding a simulation mode

andrea crotti andrea.crotti.0 at
Thu Jul 12 15:55:35 CEST 2012

One way instead that might actually work is this

def default_mock_action(func_name):
    def _default_mock_action(*args, **kwargs):
        print("running {} with args {} and {}".format(func_name, args, kwargs))

    return _default_mock_action

def mock_fs_actions(to_run):
    """Take a function to run, and run it in an environment which
    mocks all the possibly dangerous operations
    side_effect = [

    acts = dict((s, default_mock_action(s)) for s in side_effect)

    with patch('',
        with patch.multiple('shutil', **acts):

So I can just pass the main function inside the mock like

and it seems to do the job, but I have to list manually all the things
to mock and I'm not sure is the best idea anyway..

More information about the Python-list mailing list