This is not portable (ie. doesn't work on windows). One option is to port the test to Twisted Trial and use self.mktemp(), otherwise tempfile.mkstemp() should work too.