public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* Re: [gentoo-portage-dev] [PATCH] runtests: create a global tempdir to hold subtest files
  @ 2015-10-30 18:52 99% ` Zac Medico
  0 siblings, 0 replies; 1+ results
From: Zac Medico @ 2015-10-30 18:52 UTC (permalink / raw
  To: gentoo-portage-dev

On 10/30/2015 11:00 AM, Mike Frysinger wrote:

> +	try:
> +		# Set up a single tempdir for all the tests to use.
> +		# This way we know the tests won't leak things on us.
> +		tempdir = tempfile.mkdtemp(prefix='portage.runtests.')
[snip]
> +	finally:
> +		if opts.keep_temp:
> +			print('Temporary directory left behind:\n%s' % tempdir)
> +		else:
> +			# Nuke our tempdir and anything that might be under it.
> +			shutil.rmtree(tempdir, True)
>  
>  	# Then summarize it all.
>  	print('\nSummary:\n')
> 

This will raise NameError if mkdtemp for some reason. For absolute
correctness, you need to call mkdtemp before try, or set tempdir = None
before the try and check that it's not None before calling rmtree.
-- 
Thanks,
Zac


^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-10-30 18:00     [gentoo-portage-dev] [PATCH] runtests: create a global tempdir to hold subtest files Mike Frysinger
2015-10-30 18:52 99% ` Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox