from io import StringIO


def file_from_string(xml_str):
    """
    Create a fake file object with string's contents.
    """
    stringio = StringIO()
    stringio.write(xml_str)
    stringio.seek(0)
    return stringio