From: Markus Lehtonen Date: Wed, 2 Oct 2013 13:35:32 +0000 (+0300) Subject: ComponentTestBase: add a per-class toplevel temp dir X-Git-Tag: debian/0.6.23~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a84f6c1fba7772c38e810e05a1edfc909259d848;p=tools%2Fgit-buildpackage.git ComponentTestBase: add a per-class toplevel temp dir Signed-off-by: Markus Lehtonen --- diff --git a/tests/component/__init__.py b/tests/component/__init__.py index 7abb16d1..44a84e20 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)