'Create a file in the tempdir and remember it so as to close() it
before attempting to cleanup the temp dir.
@rtype: file'

def file(self, fname, mode=None):

    ffn = os.path.join(self.name, fname)
    if (mode is not None):
        fo = open(ffn, mode)
    else:
        fo = open(ffn)
    self.register_file(fo)
    return fo
