How can I create a fake file object in Python that contains text? I\'m trying to write unit tests for a method that takes in a file object and retrieves the text via readl
readl
This is exactly what StringIO/cStringIO (renamed to io.StringIO in Python 3) is for.