This looks mostly fine, but you probably should test more sources. E.g. StringIO, File, Tempfile (these are different classes), hmm, maybe something else -- I'm not sure. A socket to localhost?