From: Guido Günther Date: Thu, 27 Mar 2014 19:42:29 +0000 (+0100) Subject: Use a temporary directory X-Git-Tag: debian/0.6.11~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd440e204a6ebf62d65ff564db8c1aaa262472d2;p=tools%2Fgit-buildpackage.git Use a temporary directory This avoids file name collisions and weired files in the working copy. --- diff --git a/tests/testutils.py b/tests/testutils.py index d04f5fe9..e161dbe5 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -3,7 +3,9 @@ from . import context import os +import shutil import subprocess +import tempfile import unittest import gbp.log @@ -91,8 +93,9 @@ class MockedChangeLog(ChangeLog): def get_dch_default_urgency(): """Determine the default urgency level used by dch""" - urgency='medium' - tmp_dch_name = '__test_dch' + urgency = 'medium' + tempdir = tempfile.mkdtemp() + tmp_dch_name = os.path.join(tempdir, 'changelog') try: dch_cmd = ['dch', '--create', '--empty', '--changelog', tmp_dch_name, '--package=foo', '--newversion=1', @@ -106,7 +109,7 @@ def get_dch_default_urgency(): header = dchfile.readline().strip() urgency = header.split()[-1].replace('urgency=', '') finally: - if os.path.isfile(tmp_dch_name): - os.unlink(tmp_dch_name) + if os.path.isdir(tempdir): + shutil.rmtree(tempdir) return urgency