From a84f6c1fba7772c38e810e05a1edfc909259d848 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 2 Oct 2013 16:35:32 +0300 Subject: ComponentTestBase: add a per-class toplevel temp dir Signed-off-by: Markus Lehtonen --- tests/component/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') 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) -- cgit v1.2.3