From 3d6b68ae541d6020ff747628b3e44196999e0a50 Mon Sep 17 00:00:00 2001 From: Thomas Koch Date: Mon, 21 Jan 2013 15:50:39 +0100 Subject: 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. --- tests/testutils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests/testutils.py') diff --git a/tests/testutils.py b/tests/testutils.py index ff20e09..112bb04 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): """ -- cgit v1.2.3