1 |
On 10/30/2015 11:00 AM, Mike Frysinger wrote: |
2 |
|
3 |
> + try: |
4 |
> + # Set up a single tempdir for all the tests to use. |
5 |
> + # This way we know the tests won't leak things on us. |
6 |
> + tempdir = tempfile.mkdtemp(prefix='portage.runtests.') |
7 |
[snip] |
8 |
> + finally: |
9 |
> + if opts.keep_temp: |
10 |
> + print('Temporary directory left behind:\n%s' % tempdir) |
11 |
> + else: |
12 |
> + # Nuke our tempdir and anything that might be under it. |
13 |
> + shutil.rmtree(tempdir, True) |
14 |
> |
15 |
> # Then summarize it all. |
16 |
> print('\nSummary:\n') |
17 |
> |
18 |
|
19 |
This will raise NameError if mkdtemp for some reason. For absolute |
20 |
correctness, you need to call mkdtemp before try, or set tempdir = None |
21 |
before the try and check that it's not None before calling rmtree. |
22 |
-- |
23 |
Thanks, |
24 |
Zac |