I think this will fail on Windows, because the test process still has an open handle on the temporary file. We probably need a f.close().