summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-10-02 16:35:32 +0300
committerGuido Günther <agx@sigxcpu.org>2014-12-05 15:42:15 +0100
commita84f6c1fba7772c38e810e05a1edfc909259d848 (patch)
tree781542406a181cf48f3ecb5eddad9589b2bd68af /tests
parent410e613ac2c72e94a9e45ddd1ed3670a5ef1cf7c (diff)
ComponentTestBase: add a per-class toplevel temp dir
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/component/__init__.py9
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)