Make these triple quoted strings and put them directly in the file (I guess you can leave test1 separate because it's longer), then pass them in wrapped in StringIO. (you can add a `strip()` to the end of quotes to remove extra whitesapce)