my function reads from a file, and a doctest needs to be written in a way independent of an absolute path. What's the best way of wrting a doctest? Writing a temp file is expensive and not failproof.
Your doctest could use module StringIO to provide a file object from a string.
How to write a doctest for a function that reads from a file?