aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/testutils.py
diff options
context:
space:
mode:
authorThomas Koch <thomas@koch.ro>2013-01-21 15:50:39 +0100
committerGuido Günther <agx@sigxcpu.org>2013-04-08 07:43:02 +0200
commit3d6b68ae541d6020ff747628b3e44196999e0a50 (patch)
treebb3f94d4f9c0af6eb3a9779dbf6bbee20a512ef0 /tests/testutils.py
parent92edb4eda14cf4b5fd1514feb7b81aa50456285c (diff)
tests: Use tempfile.mkdtemp to create temp dirs for tests
This puts test dirs below /tmp which often is a tmpfs. All tests include the context module which consolidates tmpdir creation and cleanup, undoes a chdir in teardown and silences log messages.
Diffstat (limited to 'tests/testutils.py')
-rw-r--r--tests/testutils.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/testutils.py b/tests/testutils.py
index ff20e090..112bb04a 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -1,5 +1,7 @@
# vim: set fileencoding=utf-8 :
+from . import context
+
import os
import shutil
import unittest
@@ -12,16 +14,13 @@ class DebianGitTestRepo(unittest.TestCase):
"""Scratch repo for a single unit test"""
def setUp(self):
- gbp.log.setup(False, False)
- top = os.path.abspath(os.path.curdir)
- self.tmpdir = os.path.join(top, 'gbp_%s_repo' % __name__)
- os.mkdir(self.tmpdir)
+ self.tmpdir = context.new_tmpdir(__name__)
- repodir = os.path.join(self.tmpdir, 'test_repo')
+ repodir = self.tmpdir.join('test_repo')
self.repo = gbp.deb.git.DebianGitRepository.create(repodir)
def tearDown(self):
- shutil.rmtree(self.tmpdir)
+ context.teardown()
def add_file(self, name, content=None, msg=None):
"""