diff --git a/tests/nightly.TestCase b/tests/nightly.TestCase index b6d47447..9e505c7f 100755 --- a/tests/nightly.TestCase +++ b/tests/nightly.TestCase @@ -70,7 +70,10 @@ class NightlyTest(unittest.TestCase): def tearDown(self): self.tempdir.cleanup() - os.rmdir(self.testroot) + try: + os.rmdir(self.testroot) + except OSError: # other test modules might have left stuff around + pass def _copy_test_debug_keystore(self): self.dot_android.mkdir() diff --git a/tests/testcommon.py b/tests/testcommon.py index fe3728ba..069ac42e 100644 --- a/tests/testcommon.py +++ b/tests/testcommon.py @@ -18,6 +18,9 @@ import os import sys import tempfile +import unittest + +from pathlib import Path class TmpCwd: @@ -60,3 +63,12 @@ def mkdtemp(): return tempfile.TemporaryDirectory() else: return tempfile.TemporaryDirectory(ignore_cleanup_errors=True) + + +def mkdir_testfiles(localmodule, test): + """Keep the test files in a labeled test dir for easy reference""" + testroot = Path(localmodule) / '.testfiles' + testroot.mkdir(exist_ok=True) + testdir = testroot / unittest.TestCase.id(test) + testdir.mkdir(exist_ok=True) + return tempfile.mkdtemp(dir=testdir)