diff options
Diffstat (limited to 'tests/component/__init__.py')
-rw-r--r-- | tests/component/__init__.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py index 7abb16d..44a84e2 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -85,6 +85,9 @@ class ComponentTestBase(object): # Don't let git see that we're (possibly) under a git directory cls.orig_env = os.environ.copy() os.environ['GIT_CEILING_DIRECTORIES'] = os.getcwd() + # Create a top-level tmpdir for the test + cls._tmproot = tempfile.mkdtemp(prefix='gbp_%s_' % cls.__name__, + dir='.') @classmethod def teardown_class(cls): @@ -92,6 +95,9 @@ class ComponentTestBase(object): # Return original environment os.environ.clear() os.environ.update(cls.orig_env) + # Remove top-level tmpdir + if not os.getenv("GBP_TESTS_NOCLEAN"): + shutil.rmtree(cls._tmproot) def __init__(self): """Object initialization""" @@ -104,7 +110,8 @@ class ComponentTestBase(object): """Test case setup""" # Change to a temporary directory self._orig_dir = os.getcwd() - self._tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.') + self._tmpdir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, + dir=self._tmproot) os.chdir(self._tmpdir) self._capture_log(True) |