def create_file(self, filename, contents, mode='<STR_LIT:w>'):
full_path = os.path.join(self.rootdir, filename)<EOL>if not os.path.isdir(os.path.dirname(full_path)):<EOL><INDENT>os.makedirs(os.path.dirname(full_path))<EOL><DEDENT>with open(full_path, mode) as f:<EOL><INDENT>f.write(contents)<EOL><DEDENT>return full_path<EOL>
Creates a file in a tmpdir
        ``filename`` should be a relative path, e.g. "foo/bar/baz.txt"
        It will be translated into a full path in a tmp dir.
        ``mode`` is the mode the file should be opened either as ``w`` or
        `wb``.
        Returns the full path to the file.