@contextlib.contextmanager
def gen_temporary_file(name='', suffix='.qcow2', size=10485760):
 with tempfile.NamedTemporaryFile(prefix=name, suffix=suffix) as tmp_file:
  tmp_file.write(os.urandom(size))
  (yield tmp_file.name)

@ contextlib . contextmanager def gen_temporary_file ( name = '' , suffix = '.qcow2' , size = 10485760 ) : with tempfile . NamedTemporaryFile ( prefix = name , suffix = suffix ) as tmp_file : tmp_file . write ( os . urandom ( size ) ) ( yield tmp_file . name )
generate temporary file with provided parameters .