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/07_test_fastimport.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'tests/07_test_fastimport.py') diff --git a/tests/07_test_fastimport.py b/tests/07_test_fastimport.py index a23cd64d..42824f94 100644 --- a/tests/07_test_fastimport.py +++ b/tests/07_test_fastimport.py @@ -2,32 +2,28 @@ """Test L{FastImport} class""" +from . import context + import os import shutil +import tempfile import gbp.log import gbp.git repo = None fastimport = None -tmpdir = None tf_name = 'testfile' tl_name = 'a_testlink' def setup(): - global repo, tmpdir - - gbp.log.setup(False, False) - top = os.path.abspath(os.curdir) - tmpdir = os.path.join(top,'gbp_%s_repo' % __name__) - os.mkdir(tmpdir) + global repo - repodir = os.path.join(tmpdir, 'test_repo') - repo = gbp.git.GitRepository.create(repodir) + tmpdir = context.new_tmpdir(__name__) + repo = gbp.git.GitRepository.create(tmpdir.join('test_repo')) def teardown(): - if not os.getenv("GBP_TESTS_NOCLEAN") and tmpdir: - shutil.rmtree(tmpdir) + context.teardown() def test_init_fastimport(): """Create a fastimport object""" -- cgit v1.2.3