def build_mock_open_side_effect(string_d, stream_d):
assert(len(set(string_d.keys()).intersection(set(stream_d.keys()))) == <NUM_LIT:0>)<EOL>def mock_open_side_effect(*args, **kwargs):<EOL><INDENT>if args[<NUM_LIT:0>] in string_d:<EOL><INDENT>return StringIO.StringIO(string_d[args[<NUM_LIT:0>]])<EOL><DEDENT>elif args[<NUM_LIT:0>] in stream_d:<EOL><INDENT>return stream_d[args[<NUM_LIT:0>]]<EOL><DEDENT>else:<EOL><INDENT>raise IOError("<STR_LIT>" + args[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>return mock_open_side_effect<EOL>
Build a mock open side effect using a dictionary of content for the files.

:param string_d: keys are file names, values are string file contents
:param stream_d: keys are file names, values are stream of contents