![]() |
Re: adding a simulation mode
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 = [ 'copytree', 'copy', ] acts = dict((s, default_mock_action(s)) for s in side_effect) with patch('pytest.runner.commands.ShellCommand.run', default_mock_action('run')): with patch.multiple('shutil', **acts): to_run() So I can just pass the main function inside the mock like mock_fs_actions(main) 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.. |
| All times are GMT. The time now is 02:26 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.