Ejemplo n.º 1
0
def dummy_file(content, name='dummy_file', mode='rb'):
    """ Create an in-memory, file-like object.

    :param str content: the contents of the file
    :param str name: a name for the file
    :param str mode: the mode to open the file (ignored)
    :return: an object that looks like an open file handle.
    """

    data_file = StringIO(content)
    data_file.name = name
    data_file.__enter__ = lambda: None
    data_file.__exit__ = lambda extype, value, traceback: None
    return data_file