def mock_open(self, file_map):
def side_effect(filename, mode):<EOL><INDENT>if mode == '<STR_LIT:r>':<EOL><INDENT>assert filename in file_map,'<STR_LIT>' + filename + '<STR_LIT>' + str(list(file_map))<EOL><DEDENT>self.mock_is_file.side_effect = lambda f: f in file_map<EOL>return mock.mock_open(read_data=file_map[filename])(filename, mode)<EOL><DEDENT>return mock.patch('<STR_LIT>', mock.Mock(side_effect=side_effect))<EOL>
Creates a patch object for the built in open function that maps filenames to file
        contents.