Temporary file with specific file extension in Python 3
问题 I am writing some unit tests for a piece of code that takes a path and attempts to load the file if it has a known extension, then does more careful checking. In the unit test, I would like to create a temporary file that has the correct extension, but incorrect contents, in my case an empty file posing as test.tif . How can I create a temporary file while specifying the extension (or the entire name), using the tempfile module? I have looked at the NamedTemporaryFile class, as well as the