summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-10-02 16:35:32 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-11-14 14:21:38 +0200
commitc8b1be98ee7c33739d0f5d91fc7cd1dac9adac26 (patch)
treef0ce16cb721006f7294b10994e03f279501a6308 /tests
parent0125db0d285aeb34076486ad6936add54480e53c (diff)
downloadgit-buildpackage-c8b1be98ee7c33739d0f5d91fc7cd1dac9adac26.tar.gz
git-buildpackage-c8b1be98ee7c33739d0f5d91fc7cd1dac9adac26.tar.bz2
git-buildpackage-c8b1be98ee7c33739d0f5d91fc7cd1dac9adac26.zip
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 ea540368..34b70ad3 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='.')
# Prevent local config files from messing up the tests
os.environ['GBP_CONF_FILES'] = '%(top_dir)s/.gbp.conf:' \
'%(top_dir)s/debian/gbp.conf:%(git_dir)s/gbp.conf'
@@ -95,6 +98,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"""
@@ -107,7 +113,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)